#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";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
816 ms |
324 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
852 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
468 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
2 ms |
1876 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
816 ms |
324 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
468 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
816 ms |
324 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
816 ms |
324 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |