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