# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
697267 | vjudge1 | Amusement Park (CEOI19_amusementpark) | C++14 | 2572 ms | 2572 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;
typedef long long ll;
const int N=18,mod=998244353,inv=(mod+1)/2;
int n,m,u,v,f[1<<N],c[1<<N],ans;
bool a[N][N];
int main()
{
scanf("%d%d",&n,&m);
for(int i=1;i<=m;i++)
{
scanf("%d%d",&u,&v);
a[u-1][v-1]=a[v-1][u-1]=1;
}
for(int i=0;i<(1<<n);i++)
{
c[i]=-1;
for(int j=0;j<n;j++)
{
if((i>>j)&1)
{
c[i]=-c[i];
for(int k=j+1;k<n;k++)
if(((i>>k)&1)&&a[j][k]) c[i]=0;
}
if(!c[i]) break;
}
}
f[0]=1;
for(int i=1;i<(1<<n);i++)
for(int j=i;j;j=(j-1)&i)
if(c[j]) f[i]=((ll)f[i]+f[i-j]*c[j]+mod)%mod;
ans=(ll)f[(1<<n)-1]*m%mod*inv%mod;
printf("%d",ans);
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... |