Submission #985976

#TimeUsernameProblemLanguageResultExecution timeMemory
985976duckindogAmusement Park (CEOI19_amusementpark)C++17
42 / 100
3058 ms162176 KiB
#include <bits/stdc++.h> using namespace std; const int N = 18 + 10, M = 998'244'353; int n, m; int32_t main() { cin.tie(0)->sync_with_stdio(0); cin >> n >> m; vector<int> a(m + 1), b(m + 1); for (int i = 1; i <= m; ++i) cin >> a[i] >> b[i]; long long answer = 0; vector<int> vt(n); iota(vt.begin(), vt.end(), 1); unordered_map<long long, bool> mk; do { vector<int> p(n + 1); for (int i = 0; i < n; ++i) p[vt[i]] = i; long long mask = 0, cnt = 0; for (int i = 1; i <= m; ++i) if (p[a[i]] > p[b[i]]) mask |= (1ll << i - 1); if (!mk[mask]) { answer += __builtin_popcountll(mask); mk[mask] = true; } } while (next_permutation(vt.begin(), vt.end())); cout << answer % M << "\n"; }

Compilation message (stderr)

amusementpark.cpp: In function 'int32_t main()':
amusementpark.cpp:24:75: warning: suggest parentheses around '-' inside '<<' [-Wparentheses]
   24 |     for (int i = 1; i <= m; ++i) if (p[a[i]] > p[b[i]]) mask |= (1ll << i - 1);
      |                                                                         ~~^~~
amusementpark.cpp:23:25: warning: unused variable 'cnt' [-Wunused-variable]
   23 |     long long mask = 0, cnt = 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...