Submission #1062548

#TimeUsernameProblemLanguageResultExecution timeMemory
1062548thinknoexitAmusement Park (CEOI19_amusementpark)C++17
19 / 100
120 ms14536 KiB
#include<bits/stdc++.h> using namespace std; using ll = long long; const int MOD = 998244353; int a[155], b[155], p[22]; map<ll, bool> ch; int main() { cin.tie(nullptr)->sync_with_stdio(false); int n, m; cin >> n >> m; set<int> s; for (int i = 0;i < m;i++) { cin >> a[i] >> b[i]; } for (int i = 1;i <= n;i++) p[i] = i; int ans = 0; do { int now = 0; ll bit = 0; for (int i = 0;i < m;i++) { if (p[a[i]] > p[b[i]]) { now++; bit |= (1 << i); } } if (!ch.count(bit)) { ch[bit] = 1; ans = (ans + now) % MOD; } } while (next_permutation(p + 1, p + 1 + n)); cout << ans; return 0; }
#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...