# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
203798 | 2020-02-22T07:59:05 Z | dndhk | Amusement Park (CEOI19_amusementpark) | C++14 | 5 ms | 376 KB |
#include <bits/stdc++.h> #define pb push_back using namespace std; typedef pair<int, int> pii; typedef long long ll; const int MAX_N = 30; const ll MOD = 998244353; int N, M; vector<int> gp[MAX_N+1]; vector<pii> edge; int c[MAX_N+1], idx[MAX_N+1]; ll ans; vector<ll> vt; set<ll> st; void chk(){ for(int i=1; i<=N; i++) while(!gp[i].empty()) gp[i].pop_back(); ll now = 0; for(int i=0; i<M; i++){ now<<1LL; int u = edge[i].first, v = edge[i].second; if(idx[u]<idx[v]){ int t = u; u = v; v = t; now|=1LL; } gp[u].pb(v); } vt.pb(now); } int per[MAX_N+1]; int main(){ scanf("%d%d", &N, &M); for(int i=0; i<M; i++){ int x, y; scanf("%d%d", &x, &y); edge.pb({x, y}); } for(int i=0; i<N; i++){ per[i] = i+1; } while(1){ for(int i=0; i<N; i++) idx[per[i]] = i; chk(); if(!next_permutation(per, per+N)) break; } sort(vt.begin(), vt.end()); vt.erase(unique(vt.begin(), vt.end()), vt.end()); for(int i=0; i<vt.size(); i++){ for(int j=0; j<M; j++){ ans = (ans + (vt[i]%2LL)) % MOD; vt[i]/=2LL; } } cout<<ans; return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 256 KB | Output is correct |
2 | Correct | 5 ms | 376 KB | Output is correct |
3 | Correct | 4 ms | 256 KB | Output is correct |
4 | Incorrect | 5 ms | 256 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 256 KB | Output is correct |
2 | Correct | 5 ms | 376 KB | Output is correct |
3 | Correct | 4 ms | 256 KB | Output is correct |
4 | Incorrect | 5 ms | 256 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 256 KB | Output is correct |
2 | Correct | 5 ms | 376 KB | Output is correct |
3 | Correct | 4 ms | 256 KB | Output is correct |
4 | Incorrect | 5 ms | 256 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 256 KB | Output is correct |
2 | Correct | 5 ms | 376 KB | Output is correct |
3 | Correct | 4 ms | 256 KB | Output is correct |
4 | Incorrect | 5 ms | 256 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 256 KB | Output is correct |
2 | Correct | 5 ms | 376 KB | Output is correct |
3 | Correct | 4 ms | 256 KB | Output is correct |
4 | Incorrect | 5 ms | 256 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |