# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1062538 | sleepntsheep | Amusement Park (CEOI19_amusementpark) | C++17 | 3057 ms | 162008 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 <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)
# | 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... |