#include "bits/stdc++.h"
using namespace std;
#define ar array
typedef int64_t ll;
//~ #define int ll
const int N = 20;
const int P = 167;
const int mod = 119 << 23 | 1;
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<int> 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;
}
if(!ss.count(hh)){
ss.insert(hh);
res = (res + cnt) % mod;
}
}while(next_permutation(p.begin(), p.end()));
cout<<res<<"\n";
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 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 |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 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 |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 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 |
0 ms |
212 KB |
Output is correct |
15 |
Correct |
1 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 |
212 KB |
Output is correct |
21 |
Correct |
1 ms |
212 KB |
Output is correct |
22 |
Correct |
1 ms |
212 KB |
Output is correct |
23 |
Correct |
1 ms |
212 KB |
Output is correct |
24 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 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 |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 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 |
0 ms |
212 KB |
Output is correct |
15 |
Correct |
1 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 |
212 KB |
Output is correct |
21 |
Correct |
1 ms |
212 KB |
Output is correct |
22 |
Correct |
1 ms |
212 KB |
Output is correct |
23 |
Correct |
1 ms |
212 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 |
3 ms |
340 KB |
Output is correct |
29 |
Correct |
2 ms |
340 KB |
Output is correct |
30 |
Correct |
2 ms |
452 KB |
Output is correct |
31 |
Correct |
3 ms |
468 KB |
Output is correct |
32 |
Correct |
6 ms |
212 KB |
Output is correct |
33 |
Correct |
8 ms |
212 KB |
Output is correct |
34 |
Correct |
11 ms |
384 KB |
Output is correct |
35 |
Correct |
13 ms |
468 KB |
Output is correct |
36 |
Correct |
17 ms |
724 KB |
Output is correct |
37 |
Correct |
22 ms |
1356 KB |
Output is correct |
38 |
Correct |
28 ms |
2136 KB |
Output is correct |
39 |
Correct |
56 ms |
296 KB |
Output is correct |
40 |
Correct |
75 ms |
332 KB |
Output is correct |
41 |
Correct |
89 ms |
348 KB |
Output is correct |
42 |
Correct |
102 ms |
520 KB |
Output is correct |
43 |
Incorrect |
143 ms |
1552 KB |
Output isn't correct |
44 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 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 |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 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 |
0 ms |
212 KB |
Output is correct |
15 |
Correct |
1 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 |
212 KB |
Output is correct |
21 |
Correct |
1 ms |
212 KB |
Output is correct |
22 |
Correct |
1 ms |
212 KB |
Output is correct |
23 |
Correct |
1 ms |
212 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 |
3 ms |
340 KB |
Output is correct |
29 |
Correct |
2 ms |
340 KB |
Output is correct |
30 |
Correct |
2 ms |
452 KB |
Output is correct |
31 |
Correct |
3 ms |
468 KB |
Output is correct |
32 |
Correct |
6 ms |
212 KB |
Output is correct |
33 |
Correct |
8 ms |
212 KB |
Output is correct |
34 |
Correct |
11 ms |
384 KB |
Output is correct |
35 |
Correct |
13 ms |
468 KB |
Output is correct |
36 |
Correct |
17 ms |
724 KB |
Output is correct |
37 |
Correct |
22 ms |
1356 KB |
Output is correct |
38 |
Correct |
28 ms |
2136 KB |
Output is correct |
39 |
Correct |
56 ms |
296 KB |
Output is correct |
40 |
Correct |
75 ms |
332 KB |
Output is correct |
41 |
Correct |
89 ms |
348 KB |
Output is correct |
42 |
Correct |
102 ms |
520 KB |
Output is correct |
43 |
Incorrect |
143 ms |
1552 KB |
Output isn't correct |
44 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 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 |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 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 |
0 ms |
212 KB |
Output is correct |
15 |
Correct |
1 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 |
212 KB |
Output is correct |
21 |
Correct |
1 ms |
212 KB |
Output is correct |
22 |
Correct |
1 ms |
212 KB |
Output is correct |
23 |
Correct |
1 ms |
212 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 |
3 ms |
340 KB |
Output is correct |
29 |
Correct |
2 ms |
340 KB |
Output is correct |
30 |
Correct |
2 ms |
452 KB |
Output is correct |
31 |
Correct |
3 ms |
468 KB |
Output is correct |
32 |
Correct |
6 ms |
212 KB |
Output is correct |
33 |
Correct |
8 ms |
212 KB |
Output is correct |
34 |
Correct |
11 ms |
384 KB |
Output is correct |
35 |
Correct |
13 ms |
468 KB |
Output is correct |
36 |
Correct |
17 ms |
724 KB |
Output is correct |
37 |
Correct |
22 ms |
1356 KB |
Output is correct |
38 |
Correct |
28 ms |
2136 KB |
Output is correct |
39 |
Correct |
56 ms |
296 KB |
Output is correct |
40 |
Correct |
75 ms |
332 KB |
Output is correct |
41 |
Correct |
89 ms |
348 KB |
Output is correct |
42 |
Correct |
102 ms |
520 KB |
Output is correct |
43 |
Incorrect |
143 ms |
1552 KB |
Output isn't correct |
44 |
Halted |
0 ms |
0 KB |
- |