Submission #1100412

#TimeUsernameProblemLanguageResultExecution timeMemory
1100412cow123Amusement Park (CEOI19_amusementpark)C++14
0 / 100
1 ms2388 KiB
#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; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...