# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
991815 | vjudge1 | Amusement Park (CEOI19_amusementpark) | C++17 | 1901 ms | 3684 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;
int has[18][18],indep[1<<18];
long long dp[1<<18],mod=998244353;
long long ans;
int main(){
int n,m;
cin>>n>>m;
for(int i=0;i<m;i++){
int x,y;
cin>>x>>y;
x--,y--;
has[x][y]=1;
has[y][x]=1;
}
for(int i=0;i<1<<n;i++){
vector<int>v;
for(int j=0;j<n;j++)
if(i&1<<j)
v.push_back(j);
for(int j=0;j<v.size();j++)
for(int k=j+1;k<v.size();k++)
indep[i]|=has[v[j]][v[k]];
indep[i]^=1;
}
dp[0]=1;
for(int i=1;i<1<<n;i++)
for(int j=i-1&i;;j=j-1&i){
int cnt=__builtin_popcount(i)-
__builtin_popcount(j);
dp[i]=(dp[i]+mod+indep[i-j]*dp[j]*(cnt%2*2-1))%mod;
if(!j) break;
}
cout<<(mod+1)/2*dp[(1<<n)-1]%mod*m%mod;
}
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... |