Submission #1097488

#TimeUsernameProblemLanguageResultExecution timeMemory
1097488alexander707070Newspapers (CEOI21_newspapers)C++14
0 / 100
1078 ms221520 KiB
#include<bits/stdc++.h> #define MAXN 200007 using namespace std; int n,m,a,b; vector<int> v[MAXN],to[1<<22]; bool li[1<<22]; bool dfs(int x,int y){ if(x==y)return true; li[x]=true; for(int i:to[x]){ if(!li[i] and dfs(i,y))return true; } return false; } int main(){ cin>>n>>m; for(int i=1;i<=m;i++){ cin>>a>>b; a--; b--; v[a].push_back(b); v[b].push_back(a); } for(int i=0;i<(1<<n);i++){ for(int f=0;f<n;f++){ int res=0; for(int t=0;t<n;t++){ if(((1<<t)&i)>0){ for(int s:v[t])res|=(1<<s); } } if((res&(1<<f))>0)res^=(1<<f); to[i].push_back(res); } } if(dfs((1<<n)-1,0)){ cout<<"YES\n"; cout<<"1\n1\n"; }else{ cout<<"NO\n"; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...