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;
using ll = long long;
const int MOD = 998244353;
int a[155], b[155], p[22];
map<ll, bool> ch;
int main() {
cin.tie(nullptr)->sync_with_stdio(false);
int n, m;
cin >> n >> m;
set<int> s;
for (int i = 0;i < m;i++) {
cin >> a[i] >> b[i];
}
for (int i = 1;i <= n;i++) p[i] = i;
int ans = 0;
do {
int now = 0;
ll bit = 0;
for (int i = 0;i < m;i++) {
if (p[a[i]] > p[b[i]]) {
now++;
bit |= (1 << i);
}
}
if (!ch.count(bit)) {
ch[bit] = 1;
ans += now;
}
} while (next_permutation(p + 1, p + 1 + n));
cout << ans;
return 0;
}
# | 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... |