Submission #1364191
Source Code Expand
#include <bits/stdc++.h> // iostream is too mainstream #include <cstdio> // bitch please #include <iostream> #include <algorithm> #include <cstdlib> #include <vector> #include <set> #include <map> #include <queue> #include <stack> #include <list> #include <cmath> #include <iomanip> #include <time.h> #define dibs reserve #define OVER9000 1234567890 #define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++) #define tisic 47 #define soclose 1e-8 #define chocolate win // so much chocolate #define patkan 9 #define ff first #define ss second #define abs(x) ((x < 0)?-(x):x) #define uint unsigned int #define dbl long double #define pi 3.14159265358979323846 using namespace std; // mylittledoge #ifdef DONLINE_JUDGE // palindromic tree is better than splay tree! #define lld I64d #endif int main() { cin.sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(10); int N,M; cin >> N >> M; vector< vector<int> > G(N); long long ans =1, mod =1000000007; for(int i =0; i < M; i++) { ans =(ans*2)%mod; int x,y; cin >> x >> y; if(x == 1 && y == 2) continue; G[N-x].push_back(N-y);} vector< vector<int> > deg(N,vector<int>(1<<N,0)); for(int i =0; i < N; i++) for(int j =0; j < (1<<N); j++) ALL_THE(G[i],it) deg[i][j] +=(j>>*it)&1; vector<long long> cnt(1<<N,0); cnt[0] =1; for(int i =0; i < (1<<(N-2)); i++) if(cnt[i] != 0) { vector<int> v; int w,w2; for(int j =0; j < N; j++) if(((i>>j)&1) == 0) v.push_back(j); int sz =v.size(); for(int j =0; j < (1<<(sz-2)); j++) for(int k =0; k < 2; k++) { w =0; for(int a =0; a < sz-2; a++) if((j>>a)&1) w +=1<<v[a]; if(k) w +=(1<<(N-2))*3; if(w == 0) continue; w2 =(1<<N)-1-i-w; long long c =1; for(int a =0; a < N; a++) if((w2>>a)&1) c =(c*((1LL<<deg[a][w])-1))%mod; for(int a =0; a < N; a++) if((w>>a)&1) c =(c*(1LL<<deg[a][w2]))%mod; c =(c*cnt[i])%mod; cnt[i+w] =(cnt[i+w]+c)%mod;} } for(int i =0; i < (1<<N); i++) if((i>>(N-1))&1) if((i>>(N-2))&1) { long long e =1; for(int j =0; j < N; j++) if(((i>>j)&1) == 0) ALL_THE(G[j],it) if(((i>>*it)&1) == 0) e =(e*2)%mod; ans =(ans-e*cnt[i])%mod;} if(ans < 0) ans +=mod; cout << ans << "\n"; return 0;} // look at my code // my code is amazing
Submission Info
Submission Time | |
---|---|
Task | F - Games on DAG |
User | xellos |
Language | C++14 (GCC 5.4.1) |
Score | 1600 |
Code Size | 2328 Byte |
Status | AC |
Exec Time | 171 ms |
Memory | 2556 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 1600 / 1600 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | 0_00.txt, 0_01.txt, 0_02.txt, 0_03.txt |
All | 0_00.txt, 0_01.txt, 0_02.txt, 0_03.txt, 1_00.txt, 1_01.txt, 1_02.txt, 1_03.txt, 1_04.txt, 1_05.txt, 1_06.txt, 1_07.txt, 1_08.txt, 1_09.txt, 1_10.txt, 1_11.txt, 1_12.txt, 1_13.txt, 1_14.txt, 1_15.txt, 1_16.txt, 1_17.txt, 1_18.txt, 1_19.txt, 1_20.txt, 1_21.txt, 1_22.txt, 1_23.txt, 1_24.txt, 1_25.txt, 1_26.txt, 1_27.txt, 1_28.txt, 1_29.txt, 1_30.txt, 1_31.txt, 1_32.txt, 1_33.txt, 1_34.txt, 1_35.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
0_00.txt | AC | 1 ms | 256 KB |
0_01.txt | AC | 1 ms | 256 KB |
0_02.txt | AC | 1 ms | 256 KB |
0_03.txt | AC | 1 ms | 256 KB |
1_00.txt | AC | 1 ms | 256 KB |
1_01.txt | AC | 6 ms | 2556 KB |
1_02.txt | AC | 6 ms | 2556 KB |
1_03.txt | AC | 171 ms | 2556 KB |
1_04.txt | AC | 164 ms | 2556 KB |
1_05.txt | AC | 171 ms | 2556 KB |
1_06.txt | AC | 63 ms | 2556 KB |
1_07.txt | AC | 168 ms | 2556 KB |
1_08.txt | AC | 171 ms | 2556 KB |
1_09.txt | AC | 166 ms | 2556 KB |
1_10.txt | AC | 170 ms | 2556 KB |
1_11.txt | AC | 121 ms | 2556 KB |
1_12.txt | AC | 171 ms | 2556 KB |
1_13.txt | AC | 170 ms | 2556 KB |
1_14.txt | AC | 171 ms | 2556 KB |
1_15.txt | AC | 135 ms | 2556 KB |
1_16.txt | AC | 121 ms | 2556 KB |
1_17.txt | AC | 171 ms | 2556 KB |
1_18.txt | AC | 62 ms | 2556 KB |
1_19.txt | AC | 171 ms | 2556 KB |
1_20.txt | AC | 9 ms | 2556 KB |
1_21.txt | AC | 2 ms | 256 KB |
1_22.txt | AC | 53 ms | 2556 KB |
1_23.txt | AC | 56 ms | 2556 KB |
1_24.txt | AC | 7 ms | 1408 KB |
1_25.txt | AC | 1 ms | 256 KB |
1_26.txt | AC | 112 ms | 2556 KB |
1_27.txt | AC | 4 ms | 512 KB |
1_28.txt | AC | 7 ms | 2556 KB |
1_29.txt | AC | 19 ms | 768 KB |
1_30.txt | AC | 2 ms | 512 KB |
1_31.txt | AC | 160 ms | 2556 KB |
1_32.txt | AC | 19 ms | 768 KB |
1_33.txt | AC | 3 ms | 512 KB |
1_34.txt | AC | 21 ms | 1408 KB |
1_35.txt | AC | 19 ms | 768 KB |