| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 955857 | Trisanu_Das | Amusement Park (CEOI19_amusementpark) | C++17 | 2894 ms | 4728 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>
#define mod 998244353ll
#define LL long long
#define LD long double
#define MP make_pair
#define PB push_back
#define all(v) v.begin(),v.end()
using namespace std;
LL binpow(LL a,int n) {
if(n==0) return 1;
if(n%2==0) return binpow(a*a%mod,n/2);
return a*binpow(a,n-1)%mod;
}
bool inMask(int a,int mask) {
return (bool)((1<<a)&mask);
}
int n,m;
int ans[(1<<18)+10],cnt[(1<<18)+10];
vector<pair<int,int>> p;
vector<int> g[20];
bool isEdge[(1<<18)+10];
int main()
{
cin>>n>>m;
for(int i=1;i<=m;i++)
{
int a,b;
cin>>a>>b;
a--;
b--;
g[a].PB(b);
g[b].PB(a);
p.PB(MP(a,b));
}
for(int mask=0;mask<(1<<n);mask++)
{
for(int i=0;i<n;i++)
{
if(((1<<i)&mask)==0)
continue;
cnt[mask]++;
for(int j=0;j<g[i].size();j++)
isEdge[mask]|=inMask(g[i][j],mask);
}
}
ans[0]=1;
for(int mask=1;mask<(1<<n);mask++) {
int s=mask;
vector<int> S;
while(s){
S.PB(s);
s=(s-1)&mask;
}
while(!S.empty()) {
s=S.back();
S.pop_back();
if(isEdge[s])
continue;
if(cnt[s]%2==1)
ans[mask]+=ans[mask^s];
else
ans[mask]+=mod-ans[mask^s];
ans[mask]%=mod;
}
}
LL answ=ans[(1<<n)-1];
answ*=(LL)m;
answ%=mod;
answ*=binpow(2,mod-2);
answ%=mod;
cout<<answ<<endl;
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... | ||||
