Submission #579377

#TimeUsernameProblemLanguageResultExecution timeMemory
579377amunduzbaevAmusement Park (CEOI19_amusementpark)C++17
19 / 100
184 ms5916 KiB
#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 = 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<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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...