# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
696780 | vjudge1 | Amusement Park (CEOI19_amusementpark) | C++17 | 2377 ms | 3720 KiB |
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;
const int N=18,mod=998244353,inv2=499122177;
int n,m,a[500],b[500],coef[1<<N],dp[1<<N],d[1<<N];
int main(){
scanf("%d%d",&n,&m);
dp[0]=1;
coef[0]=mod-1;
for(int i=1;i<1<<n;i++)coef[i]=mod-coef[i&(i-1)];
for(int i=1;i<=m;i++)scanf("%d%d",&a[i],&b[i]),a[i]--,b[i]--;
for(int i=1;i<1<<n;i++){
for(int o=1;o<=m;o++){
if((i>>a[o]&1)&&(i>>b[o]&1))d[i]=1;
}
}
for(int i=1;i<1<<n;i++){
for(int o=i;o;o=((o-1)&i)){
if(!d[o])dp[i]=(dp[i]+1ll*dp[i^o]*coef[o])%mod;
}
}
printf("%lld\n",1ll*dp[(1<<n)-1]*m%mod*inv2%mod);
return 0;
}
Compilation message (stderr)
# | 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... |