# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
203799 | dndhk | Amusement Park (CEOI19_amusementpark) | C++14 | 3088 ms | 33544 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |