Submission #1062538

#TimeUsernameProblemLanguageResultExecution timeMemory
1062538sleepntsheepAmusement Park (CEOI19_amusementpark)C++17
42 / 100
3057 ms162008 KiB
#include <stdio.h> #include <algorithm> #include <unordered_set> using namespace std; using ll = long long; int n, m, a[999], b[999], p[22], q[22]; int main() { scanf("%d%d", &n, &m); for (int i = 0; i < m; ++i) scanf("%d%d", a+i, b+i), --a[i], --b[i]; ll ans {}; unordered_set<ll> vis; for (int i = 0; i < n; ++i) p[i] = i; do { for (int j = 0; j < n; ++j) q[p[j]] = j; ll z {}, y {}; for (int i = 0; i < m; ++i) { if (q[a[i]] < q[b[i]]) z |= 1ll << i, ++y; } if (not vis.count(z)) vis.insert(z), ans += y; } while (next_permutation(p, p + n)); printf("%lld", ans % 998244353); }

Compilation message (stderr)

amusementpark.cpp: In function 'int main()':
amusementpark.cpp:11:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |   scanf("%d%d", &n, &m);
      |   ~~~~~^~~~~~~~~~~~~~~~
amusementpark.cpp:13:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |     scanf("%d%d", a+i, b+i), --a[i], --b[i];
      |     ~~~~~^~~~~~~~~~~~~~~~~~
#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...