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 <algorithm>
#include <bits/stdc++.h>
using namespace std;
signed main() {
cin.tie(0)->sync_with_stdio(0);
cin.exceptions(cin.failbit);
int n, m;
cin >> n >> m;
vector<int> ht(n);
vector<pair<int, int>> vpii(m);
for (auto &a : vpii) {
cin >> a.first >> a.second;
a.first--, a.second--;
}
iota(ht.begin(), ht.end(), 0);
long long sumc = 0;
const int mod = 998244353;
set<long long> svi;
auto hsh = [](vector<int> &vi) {
int each = 11;
long long cur = 0;
for (auto a : vi) {
cur *= each;
cur += a;
}
return cur;
};
do {
vector<int> real;
int curs = 0;
for (auto a : vpii) {
if ((ht[a.first] > ht[a.second])) {
curs++;
real.emplace_back(a.second);
real.emplace_back(a.first);
}
real.emplace_back(a.first);
real.emplace_back(a.second);
}
auto it = svi.insert(hsh(real));
if (it.second) {
sumc += curs;
sumc %= mod;
}
} while (next_permutation(ht.begin(), ht.end()));
cout << sumc << "\n";
}
# | 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... |