#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;
//~ }
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 |
0 ms |
212 KB |
Output is correct |
3 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |