Submission #1083613

#TimeUsernameProblemLanguageResultExecution timeMemory
1083613doducanhAmusement Park (CEOI19_amusementpark)C++14
100 / 100
2308 ms2924 KiB
///breaker #pragma GCC optimize("O3") #include<bits/stdc++.h> using namespace std; #define ll long long #define fi first #define se second #define ii pair<int,int> #define mp make_pair #define in(x) freopen(x,"r",stdin) #define out(x) freopen(x,"w",stdout) #define bit(x,i) ((x>>i)&1) #define lc (id<<1) #define rc ((id<<1)^1) const int mod=998244353; bool independ[(1<<20)]; int a[20]; ll f[(1<<20)]; int nodeid[(1<<20)]; int n,m; ll Pow(ll a,ll b) { ll res=1; for(;b;b/=2,a=(a*a)%mod)if(b&1)res=(res*a)%mod; return res; } void sol(void){ cin>>n>>m; for(int i=1;i<=m;i++){ int u,v; cin>>u>>v; u--; v--; a[u]|=(1<<v); a[v]|=(1<<u); } for(int i=0;i<n;i++)nodeid[(1<<i)]=i; independ[0]=1; for(int i=1;i<(1<<n);i++){ if(independ[(i&(i-1))]&&(a[nodeid[(i&(-i))]]&(i&(i-1)))==0){ independ[i]=1; } } f[0]=1; for(int i=1;i<(1<<n);i++){ for(int j=i;j;j=((j-1)&i)){ if(independ[j]){ int tmp=(((__builtin_popcount(j)+1)&1)?-1:1); f[i]=(f[i]+tmp*f[i^j]+mod)%mod; } } } cout<<(1ll*m*f[(1<<n)-1]%mod*Pow(2,mod-2))%mod; } signed main(void) { ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); int t=1; while(t--){ sol(); } // you should actually read the stuff at the bottom return 0; } /* stuff you should look for * int overflow, array bounds * special cases (n=1?) * do smth instead of nothing and stay organized * WRITE STUFF DOWN * DON'T GET STUCK ON ONE APPROACH */
#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...