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
typedef array<int, 2> pii;
int a[200], b[200];
int32_t main(){
int n, m; cin >> n >> m;
for(int i=0; i<m; ++i){
cin >> a[i] >> b[i];
--a[i], --b[i];
}
unordered_set<int> ans;
vector<int> perm(n);
for(int i=0; i<n; ++i) perm[i] = i; //height of ith start point
int ret = 0;
do {
int x = 0;
int y = 0;
for(int i=0; i<m; ++i){
if(perm[a[i]] < perm[b[i]]) x |= 1ll << i, ++y;
}
if(!ans.count(x)){
ans.insert(x);
ret += y;
}
} while(next_permutation(perm.begin(), perm.end()));
cout << ret % 998244353 << endl;
}
# | 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... |