#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i = a; i < b;++i)
#define int long long
#define pb push_back
using namespace std;
const int M = 998244353,maxn = 19;
vector<int> V[maxn];
int dp[(1 << maxn)],check[(1 << maxn)];
int fastp(int a,int b){
int x = 1;
while(a > 0){
if(a % 2){
x*=b;
x%=M;
}
b*=b;
b%=M;
a/=2;
}
return x;
}
int32_t main(){
int n,m;
cin>>n >>m;
FOR(i,0,m){
int x,y;
cin>>x >>y;
V[x].pb(y);
V[y].pb(x);
}
FOR(i,0,(1 << n)){
FOR(j,0,n){
if((i & (1 << j))){
for(auto y : V[j + 1]){
if(((1 << (y - 1))) & i){
check[i] = 1;
}
}
}
}
}
dp[0] = 1;
FOR(i,1,(1 << n)){
for(int j = i; j > 0; j = ((j - 1) & i)){
dp[i]+=dp[j] * (1 - check[i - j]);
dp[i]%=M;
}
dp[i]+=dp[0] * (1 - check[i]);
dp[i]%=M;
}
cout<<(dp[(1 << n) - 1] * ((fastp(M - 2,2) * m) % M)) % M;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2388 KB |
Output is correct |
2 |
Correct |
1 ms |
2388 KB |
Output is correct |
3 |
Incorrect |
1 ms |
2388 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2388 KB |
Output is correct |
2 |
Correct |
1 ms |
2388 KB |
Output is correct |
3 |
Incorrect |
1 ms |
2388 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2388 KB |
Output is correct |
2 |
Correct |
1 ms |
2388 KB |
Output is correct |
3 |
Incorrect |
1 ms |
2388 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2388 KB |
Output is correct |
2 |
Correct |
1 ms |
2388 KB |
Output is correct |
3 |
Incorrect |
1 ms |
2388 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2388 KB |
Output is correct |
2 |
Correct |
1 ms |
2388 KB |
Output is correct |
3 |
Incorrect |
1 ms |
2388 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |