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 MAXN 200007
using namespace std;
int n,m,a,b;
vector<int> v[MAXN],to[1<<22];
bool li[1<<22];
int nei[MAXN];
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);
nei[a]|=(1<<b);
nei[b]|=(1<<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){
res|=nei[t];
}
}
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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |