# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
985976 | duckindog | Amusement Park (CEOI19_amusementpark) | C++17 | 3058 ms | 162176 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>
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)
# | 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... |