#include<bits/stdc++.h>
#define MAXN 600007
using namespace std;
const int mod=998244353;
const long long modd=1e15+1;
int n,m,a[4000],b[4000];
int perm[20],ans;
long long power[4000];
unordered_map<long long,int> s;
void check(){
int c=0;
long long hesh;
for(int i=1;i<=m;i++){
if(perm[a[i]]>perm[b[i]]){
c++; hesh+=power[i];
}
}
s[hesh]=c;
}
int main(){
cin>>n>>m;
power[0]=1;
for(int i=1;i<=m;i++){
cin>>a[i]>>b[i];
power[i]=(power[i-1]*2)%modd;
}
for(int i=1;i<=n;i++)perm[i]=i;
do{
check();
}while(next_permutation(perm+1,perm+n+1));
for(pair<long long,int> curr:s){
ans+=curr.second; ans%=mod;
}
cout<<ans<<"\n";
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |