Submission #983388

#TimeUsernameProblemLanguageResultExecution timeMemory
983388duckindogAmusement Park (CEOI19_amusementpark)C++17
19 / 100
7 ms1464 KiB
#include <bits/stdc++.h> using namespace std; const int N = 18 + 10, M = 998'244'353; int n, m; int a[N], b[N]; int32_t main() { cin.tie(0)->sync_with_stdio(0); cin >> n >> m; 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; for (int i = 1; i <= m; ++i) if (p[a[i]] > p[b[i]]) mask |= (1 << i - 1); if (!mk[mask]) answer += __builtin_popcount(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:73: warning: suggest parentheses around '-' inside '<<' [-Wparentheses]
   24 |     for (int i = 1; i <= m; ++i) if (p[a[i]] > p[b[i]]) mask |= (1 << i - 1);
      |                                                                       ~~^~~
#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...