#include "bits/stdc++.h"
using namespace std;
#define ar array
typedef int64_t ll;
//~ #define int ll
const int N = 20;
const int P = 487;
const int mod = 119 << 23 | 1;
const int P2 = 167;
const int mod2 = 1e9 + 9;
vector<int> edges[N], qwe[N];
int used[N], is[N][N], cur[N];
signed main(){
ios::sync_with_stdio(0); cin.tie(0);
int n, m; cin>>n>>m;
vector<ar<int, 2>> e(m);
for(int i=0;i<m;i++){
cin>>e[i][0]>>e[i][1];
edges[e[i][0]].push_back(e[i][1]);
edges[e[i][1]].push_back(e[i][0]);
is[e[i][0]][e[i][1]] = 1;
}
for(int i=1;i<=n;i++) sort(edges[i].begin(), edges[i].end());
vector<int> p(n);
iota(p.begin(), p.end(), 1);
set<ar<int, 2>> ss;
int res = 0;
do{
memset(used, 0, sizeof used);
int cnt = 0;
for(auto u : p){
cur[u] = 0;
qwe[u].clear();
for(auto x : edges[u]){
if(used[x]) continue;
qwe[u].push_back(x);
cur[u] |= (1 << x);
if(!is[u][x]) cnt++;
}
used[u] = 1;
}
int hh = 0;
for(int i=1;i<=n;i++){
hh = (hh * 1ll * P + cur[i]) % mod;
}
int h2 = 0;
for(int i=1;i<=n;i++){
h2 = (h2 * 1ll * P2 + cur[i]) % mod2;
}
if(!ss.count({hh, h2})){
ss.insert({hh, h2});
res = (res + cnt) % mod;
}
}while(next_permutation(p.begin(), p.end()));
cout<<res<<"\n";
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
324 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
1 ms |
212 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
1 ms |
212 KB |
Output is correct |
19 |
Correct |
1 ms |
212 KB |
Output is correct |
20 |
Correct |
1 ms |
324 KB |
Output is correct |
21 |
Correct |
1 ms |
212 KB |
Output is correct |
22 |
Correct |
1 ms |
320 KB |
Output is correct |
23 |
Correct |
1 ms |
340 KB |
Output is correct |
24 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
324 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
1 ms |
212 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
1 ms |
212 KB |
Output is correct |
19 |
Correct |
1 ms |
212 KB |
Output is correct |
20 |
Correct |
1 ms |
324 KB |
Output is correct |
21 |
Correct |
1 ms |
212 KB |
Output is correct |
22 |
Correct |
1 ms |
320 KB |
Output is correct |
23 |
Correct |
1 ms |
340 KB |
Output is correct |
24 |
Correct |
1 ms |
340 KB |
Output is correct |
25 |
Correct |
1 ms |
212 KB |
Output is correct |
26 |
Correct |
2 ms |
212 KB |
Output is correct |
27 |
Correct |
2 ms |
212 KB |
Output is correct |
28 |
Correct |
2 ms |
340 KB |
Output is correct |
29 |
Correct |
2 ms |
340 KB |
Output is correct |
30 |
Correct |
3 ms |
468 KB |
Output is correct |
31 |
Correct |
3 ms |
448 KB |
Output is correct |
32 |
Correct |
10 ms |
324 KB |
Output is correct |
33 |
Correct |
9 ms |
212 KB |
Output is correct |
34 |
Correct |
12 ms |
324 KB |
Output is correct |
35 |
Correct |
13 ms |
468 KB |
Output is correct |
36 |
Correct |
16 ms |
776 KB |
Output is correct |
37 |
Correct |
23 ms |
1392 KB |
Output is correct |
38 |
Correct |
25 ms |
2208 KB |
Output is correct |
39 |
Correct |
72 ms |
212 KB |
Output is correct |
40 |
Correct |
92 ms |
324 KB |
Output is correct |
41 |
Correct |
104 ms |
364 KB |
Output is correct |
42 |
Correct |
110 ms |
432 KB |
Output is correct |
43 |
Correct |
146 ms |
1548 KB |
Output is correct |
44 |
Correct |
182 ms |
2776 KB |
Output is correct |
45 |
Correct |
221 ms |
5876 KB |
Output is correct |
46 |
Correct |
346 ms |
10892 KB |
Output is correct |
47 |
Correct |
414 ms |
17248 KB |
Output is correct |
48 |
Correct |
84 ms |
212 KB |
Output is correct |
49 |
Correct |
96 ms |
448 KB |
Output is correct |
50 |
Correct |
93 ms |
460 KB |
Output is correct |
51 |
Correct |
99 ms |
460 KB |
Output is correct |
52 |
Correct |
751 ms |
300 KB |
Output is correct |
53 |
Correct |
1004 ms |
464 KB |
Output is correct |
54 |
Correct |
1140 ms |
648 KB |
Output is correct |
55 |
Correct |
1377 ms |
1828 KB |
Output is correct |
56 |
Correct |
1700 ms |
8756 KB |
Output is correct |
57 |
Correct |
2241 ms |
22688 KB |
Output is correct |
58 |
Execution timed out |
3081 ms |
48388 KB |
Time limit exceeded |
59 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
324 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
1 ms |
212 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
1 ms |
212 KB |
Output is correct |
19 |
Correct |
1 ms |
212 KB |
Output is correct |
20 |
Correct |
1 ms |
324 KB |
Output is correct |
21 |
Correct |
1 ms |
212 KB |
Output is correct |
22 |
Correct |
1 ms |
320 KB |
Output is correct |
23 |
Correct |
1 ms |
340 KB |
Output is correct |
24 |
Correct |
1 ms |
340 KB |
Output is correct |
25 |
Correct |
1 ms |
212 KB |
Output is correct |
26 |
Correct |
2 ms |
212 KB |
Output is correct |
27 |
Correct |
2 ms |
212 KB |
Output is correct |
28 |
Correct |
2 ms |
340 KB |
Output is correct |
29 |
Correct |
2 ms |
340 KB |
Output is correct |
30 |
Correct |
3 ms |
468 KB |
Output is correct |
31 |
Correct |
3 ms |
448 KB |
Output is correct |
32 |
Correct |
10 ms |
324 KB |
Output is correct |
33 |
Correct |
9 ms |
212 KB |
Output is correct |
34 |
Correct |
12 ms |
324 KB |
Output is correct |
35 |
Correct |
13 ms |
468 KB |
Output is correct |
36 |
Correct |
16 ms |
776 KB |
Output is correct |
37 |
Correct |
23 ms |
1392 KB |
Output is correct |
38 |
Correct |
25 ms |
2208 KB |
Output is correct |
39 |
Correct |
72 ms |
212 KB |
Output is correct |
40 |
Correct |
92 ms |
324 KB |
Output is correct |
41 |
Correct |
104 ms |
364 KB |
Output is correct |
42 |
Correct |
110 ms |
432 KB |
Output is correct |
43 |
Correct |
146 ms |
1548 KB |
Output is correct |
44 |
Correct |
182 ms |
2776 KB |
Output is correct |
45 |
Correct |
221 ms |
5876 KB |
Output is correct |
46 |
Correct |
346 ms |
10892 KB |
Output is correct |
47 |
Correct |
414 ms |
17248 KB |
Output is correct |
48 |
Correct |
84 ms |
212 KB |
Output is correct |
49 |
Correct |
96 ms |
448 KB |
Output is correct |
50 |
Correct |
93 ms |
460 KB |
Output is correct |
51 |
Correct |
99 ms |
460 KB |
Output is correct |
52 |
Correct |
751 ms |
300 KB |
Output is correct |
53 |
Correct |
1004 ms |
464 KB |
Output is correct |
54 |
Correct |
1140 ms |
648 KB |
Output is correct |
55 |
Correct |
1377 ms |
1828 KB |
Output is correct |
56 |
Correct |
1700 ms |
8756 KB |
Output is correct |
57 |
Correct |
2241 ms |
22688 KB |
Output is correct |
58 |
Execution timed out |
3081 ms |
48388 KB |
Time limit exceeded |
59 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
324 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
1 ms |
212 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
1 ms |
212 KB |
Output is correct |
19 |
Correct |
1 ms |
212 KB |
Output is correct |
20 |
Correct |
1 ms |
324 KB |
Output is correct |
21 |
Correct |
1 ms |
212 KB |
Output is correct |
22 |
Correct |
1 ms |
320 KB |
Output is correct |
23 |
Correct |
1 ms |
340 KB |
Output is correct |
24 |
Correct |
1 ms |
340 KB |
Output is correct |
25 |
Correct |
1 ms |
212 KB |
Output is correct |
26 |
Correct |
2 ms |
212 KB |
Output is correct |
27 |
Correct |
2 ms |
212 KB |
Output is correct |
28 |
Correct |
2 ms |
340 KB |
Output is correct |
29 |
Correct |
2 ms |
340 KB |
Output is correct |
30 |
Correct |
3 ms |
468 KB |
Output is correct |
31 |
Correct |
3 ms |
448 KB |
Output is correct |
32 |
Correct |
10 ms |
324 KB |
Output is correct |
33 |
Correct |
9 ms |
212 KB |
Output is correct |
34 |
Correct |
12 ms |
324 KB |
Output is correct |
35 |
Correct |
13 ms |
468 KB |
Output is correct |
36 |
Correct |
16 ms |
776 KB |
Output is correct |
37 |
Correct |
23 ms |
1392 KB |
Output is correct |
38 |
Correct |
25 ms |
2208 KB |
Output is correct |
39 |
Correct |
72 ms |
212 KB |
Output is correct |
40 |
Correct |
92 ms |
324 KB |
Output is correct |
41 |
Correct |
104 ms |
364 KB |
Output is correct |
42 |
Correct |
110 ms |
432 KB |
Output is correct |
43 |
Correct |
146 ms |
1548 KB |
Output is correct |
44 |
Correct |
182 ms |
2776 KB |
Output is correct |
45 |
Correct |
221 ms |
5876 KB |
Output is correct |
46 |
Correct |
346 ms |
10892 KB |
Output is correct |
47 |
Correct |
414 ms |
17248 KB |
Output is correct |
48 |
Correct |
84 ms |
212 KB |
Output is correct |
49 |
Correct |
96 ms |
448 KB |
Output is correct |
50 |
Correct |
93 ms |
460 KB |
Output is correct |
51 |
Correct |
99 ms |
460 KB |
Output is correct |
52 |
Correct |
751 ms |
300 KB |
Output is correct |
53 |
Correct |
1004 ms |
464 KB |
Output is correct |
54 |
Correct |
1140 ms |
648 KB |
Output is correct |
55 |
Correct |
1377 ms |
1828 KB |
Output is correct |
56 |
Correct |
1700 ms |
8756 KB |
Output is correct |
57 |
Correct |
2241 ms |
22688 KB |
Output is correct |
58 |
Execution timed out |
3081 ms |
48388 KB |
Time limit exceeded |
59 |
Halted |
0 ms |
0 KB |
- |