#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);
int res = 0;
vector<ar<int, 3>> tot;
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;
}
tot.push_back({hh, h2, cnt});
//~ if(!ss.count({hh, h2})){
//~ ss.insert({hh, h2});
//~ res = (res + cnt) % mod;
//~ }
}while(next_permutation(p.begin(), p.end()));
sort(tot.begin(), tot.end());
for(int i=0;i<(int)tot.size();i++){
if(!i || tot[i] != tot[i-1]){
res += tot[i][2];
if(res >= mod) res -= mod;
}
}
cout<<res<<"\n";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 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 |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 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 |
0 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 |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
0 ms |
212 KB |
Output is correct |
13 |
Correct |
0 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
0 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 |
0 ms |
212 KB |
Output is correct |
20 |
Correct |
1 ms |
340 KB |
Output is correct |
21 |
Correct |
1 ms |
340 KB |
Output is correct |
22 |
Correct |
1 ms |
340 KB |
Output is correct |
23 |
Correct |
2 ms |
340 KB |
Output is correct |
24 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 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 |
0 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 |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
0 ms |
212 KB |
Output is correct |
13 |
Correct |
0 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
0 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 |
0 ms |
212 KB |
Output is correct |
20 |
Correct |
1 ms |
340 KB |
Output is correct |
21 |
Correct |
1 ms |
340 KB |
Output is correct |
22 |
Correct |
1 ms |
340 KB |
Output is correct |
23 |
Correct |
2 ms |
340 KB |
Output is correct |
24 |
Correct |
1 ms |
340 KB |
Output is correct |
25 |
Correct |
2 ms |
468 KB |
Output is correct |
26 |
Correct |
2 ms |
468 KB |
Output is correct |
27 |
Correct |
2 ms |
468 KB |
Output is correct |
28 |
Correct |
2 ms |
468 KB |
Output is correct |
29 |
Correct |
2 ms |
468 KB |
Output is correct |
30 |
Correct |
2 ms |
468 KB |
Output is correct |
31 |
Correct |
2 ms |
468 KB |
Output is correct |
32 |
Correct |
10 ms |
1232 KB |
Output is correct |
33 |
Correct |
12 ms |
1236 KB |
Output is correct |
34 |
Correct |
12 ms |
1152 KB |
Output is correct |
35 |
Correct |
16 ms |
1160 KB |
Output is correct |
36 |
Correct |
17 ms |
1236 KB |
Output is correct |
37 |
Correct |
20 ms |
1236 KB |
Output is correct |
38 |
Correct |
17 ms |
1144 KB |
Output is correct |
39 |
Correct |
108 ms |
6556 KB |
Output is correct |
40 |
Correct |
111 ms |
6548 KB |
Output is correct |
41 |
Correct |
130 ms |
6592 KB |
Output is correct |
42 |
Correct |
147 ms |
6572 KB |
Output is correct |
43 |
Correct |
153 ms |
6604 KB |
Output is correct |
44 |
Correct |
151 ms |
6508 KB |
Output is correct |
45 |
Correct |
168 ms |
6600 KB |
Output is correct |
46 |
Correct |
173 ms |
6588 KB |
Output is correct |
47 |
Correct |
194 ms |
6676 KB |
Output is correct |
48 |
Correct |
97 ms |
6532 KB |
Output is correct |
49 |
Correct |
121 ms |
6540 KB |
Output is correct |
50 |
Correct |
118 ms |
6540 KB |
Output is correct |
51 |
Correct |
126 ms |
6588 KB |
Output is correct |
52 |
Correct |
1099 ms |
49684 KB |
Output is correct |
53 |
Correct |
1320 ms |
49728 KB |
Output is correct |
54 |
Correct |
1445 ms |
49688 KB |
Output is correct |
55 |
Correct |
1580 ms |
49756 KB |
Output is correct |
56 |
Correct |
1669 ms |
49792 KB |
Output is correct |
57 |
Correct |
1812 ms |
49712 KB |
Output is correct |
58 |
Correct |
1906 ms |
49784 KB |
Output is correct |
59 |
Correct |
1897 ms |
49860 KB |
Output is correct |
60 |
Correct |
1938 ms |
49680 KB |
Output is correct |
61 |
Correct |
1093 ms |
49628 KB |
Output is correct |
62 |
Correct |
1311 ms |
49668 KB |
Output is correct |
63 |
Correct |
1308 ms |
49736 KB |
Output is correct |
64 |
Correct |
1278 ms |
49640 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 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 |
0 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 |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
0 ms |
212 KB |
Output is correct |
13 |
Correct |
0 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
0 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 |
0 ms |
212 KB |
Output is correct |
20 |
Correct |
1 ms |
340 KB |
Output is correct |
21 |
Correct |
1 ms |
340 KB |
Output is correct |
22 |
Correct |
1 ms |
340 KB |
Output is correct |
23 |
Correct |
2 ms |
340 KB |
Output is correct |
24 |
Correct |
1 ms |
340 KB |
Output is correct |
25 |
Correct |
2 ms |
468 KB |
Output is correct |
26 |
Correct |
2 ms |
468 KB |
Output is correct |
27 |
Correct |
2 ms |
468 KB |
Output is correct |
28 |
Correct |
2 ms |
468 KB |
Output is correct |
29 |
Correct |
2 ms |
468 KB |
Output is correct |
30 |
Correct |
2 ms |
468 KB |
Output is correct |
31 |
Correct |
2 ms |
468 KB |
Output is correct |
32 |
Correct |
10 ms |
1232 KB |
Output is correct |
33 |
Correct |
12 ms |
1236 KB |
Output is correct |
34 |
Correct |
12 ms |
1152 KB |
Output is correct |
35 |
Correct |
16 ms |
1160 KB |
Output is correct |
36 |
Correct |
17 ms |
1236 KB |
Output is correct |
37 |
Correct |
20 ms |
1236 KB |
Output is correct |
38 |
Correct |
17 ms |
1144 KB |
Output is correct |
39 |
Correct |
108 ms |
6556 KB |
Output is correct |
40 |
Correct |
111 ms |
6548 KB |
Output is correct |
41 |
Correct |
130 ms |
6592 KB |
Output is correct |
42 |
Correct |
147 ms |
6572 KB |
Output is correct |
43 |
Correct |
153 ms |
6604 KB |
Output is correct |
44 |
Correct |
151 ms |
6508 KB |
Output is correct |
45 |
Correct |
168 ms |
6600 KB |
Output is correct |
46 |
Correct |
173 ms |
6588 KB |
Output is correct |
47 |
Correct |
194 ms |
6676 KB |
Output is correct |
48 |
Correct |
97 ms |
6532 KB |
Output is correct |
49 |
Correct |
121 ms |
6540 KB |
Output is correct |
50 |
Correct |
118 ms |
6540 KB |
Output is correct |
51 |
Correct |
126 ms |
6588 KB |
Output is correct |
52 |
Correct |
1099 ms |
49684 KB |
Output is correct |
53 |
Correct |
1320 ms |
49728 KB |
Output is correct |
54 |
Correct |
1445 ms |
49688 KB |
Output is correct |
55 |
Correct |
1580 ms |
49756 KB |
Output is correct |
56 |
Correct |
1669 ms |
49792 KB |
Output is correct |
57 |
Correct |
1812 ms |
49712 KB |
Output is correct |
58 |
Correct |
1906 ms |
49784 KB |
Output is correct |
59 |
Correct |
1897 ms |
49860 KB |
Output is correct |
60 |
Correct |
1938 ms |
49680 KB |
Output is correct |
61 |
Correct |
1093 ms |
49628 KB |
Output is correct |
62 |
Correct |
1311 ms |
49668 KB |
Output is correct |
63 |
Correct |
1308 ms |
49736 KB |
Output is correct |
64 |
Correct |
1278 ms |
49640 KB |
Output is correct |
65 |
Execution timed out |
3077 ms |
98996 KB |
Time limit exceeded |
66 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 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 |
0 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 |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
0 ms |
212 KB |
Output is correct |
13 |
Correct |
0 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
0 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 |
0 ms |
212 KB |
Output is correct |
20 |
Correct |
1 ms |
340 KB |
Output is correct |
21 |
Correct |
1 ms |
340 KB |
Output is correct |
22 |
Correct |
1 ms |
340 KB |
Output is correct |
23 |
Correct |
2 ms |
340 KB |
Output is correct |
24 |
Correct |
1 ms |
340 KB |
Output is correct |
25 |
Correct |
2 ms |
468 KB |
Output is correct |
26 |
Correct |
2 ms |
468 KB |
Output is correct |
27 |
Correct |
2 ms |
468 KB |
Output is correct |
28 |
Correct |
2 ms |
468 KB |
Output is correct |
29 |
Correct |
2 ms |
468 KB |
Output is correct |
30 |
Correct |
2 ms |
468 KB |
Output is correct |
31 |
Correct |
2 ms |
468 KB |
Output is correct |
32 |
Correct |
10 ms |
1232 KB |
Output is correct |
33 |
Correct |
12 ms |
1236 KB |
Output is correct |
34 |
Correct |
12 ms |
1152 KB |
Output is correct |
35 |
Correct |
16 ms |
1160 KB |
Output is correct |
36 |
Correct |
17 ms |
1236 KB |
Output is correct |
37 |
Correct |
20 ms |
1236 KB |
Output is correct |
38 |
Correct |
17 ms |
1144 KB |
Output is correct |
39 |
Correct |
108 ms |
6556 KB |
Output is correct |
40 |
Correct |
111 ms |
6548 KB |
Output is correct |
41 |
Correct |
130 ms |
6592 KB |
Output is correct |
42 |
Correct |
147 ms |
6572 KB |
Output is correct |
43 |
Correct |
153 ms |
6604 KB |
Output is correct |
44 |
Correct |
151 ms |
6508 KB |
Output is correct |
45 |
Correct |
168 ms |
6600 KB |
Output is correct |
46 |
Correct |
173 ms |
6588 KB |
Output is correct |
47 |
Correct |
194 ms |
6676 KB |
Output is correct |
48 |
Correct |
97 ms |
6532 KB |
Output is correct |
49 |
Correct |
121 ms |
6540 KB |
Output is correct |
50 |
Correct |
118 ms |
6540 KB |
Output is correct |
51 |
Correct |
126 ms |
6588 KB |
Output is correct |
52 |
Correct |
1099 ms |
49684 KB |
Output is correct |
53 |
Correct |
1320 ms |
49728 KB |
Output is correct |
54 |
Correct |
1445 ms |
49688 KB |
Output is correct |
55 |
Correct |
1580 ms |
49756 KB |
Output is correct |
56 |
Correct |
1669 ms |
49792 KB |
Output is correct |
57 |
Correct |
1812 ms |
49712 KB |
Output is correct |
58 |
Correct |
1906 ms |
49784 KB |
Output is correct |
59 |
Correct |
1897 ms |
49860 KB |
Output is correct |
60 |
Correct |
1938 ms |
49680 KB |
Output is correct |
61 |
Correct |
1093 ms |
49628 KB |
Output is correct |
62 |
Correct |
1311 ms |
49668 KB |
Output is correct |
63 |
Correct |
1308 ms |
49736 KB |
Output is correct |
64 |
Correct |
1278 ms |
49640 KB |
Output is correct |
65 |
Execution timed out |
3077 ms |
98996 KB |
Time limit exceeded |
66 |
Halted |
0 ms |
0 KB |
- |