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;
#define int long long
const int mod = 998244353;
const int logn = 60;
int n, m;
vector<int> a;
vector<int> b;
unordered_set<int> s;
int po[logn];
void solve() {
po[0] = 1;
for(int i = 1; i < logn; i++) {
po[i] = 2 * po[i - 1];
}
cin >> n >> m;
a.assign(m, 0);
b.assign(m, 0);
for(int i = 0; i < m; i++) {
cin >> a[i] >> b[i];
a[i]--;
b[i]--;
}
vector<int> v(n, 0);
for(int i = 0; i < n; i++) {
v[i] = i;
}
do {
int c = 0;
for(int i = 0; i < m; i++) {
c |= (v[a[i]] > v[b[i]]) * po[i];
}
s.insert(c);
} while(next_permutation(v.begin(), v.end()));
int ans = 0;
for(int x : s) {
ans = ans + __builtin_popcountll(x);
}
ans %= mod;
cout << ans << "\n";
}
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
solve();
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... |