Submission #703526

#TimeUsernameProblemLanguageResultExecution timeMemory
703526PacybwoahLogičari (COCI21_logicari)C++14
20 / 110
79 ms6888 KiB
#include<iostream> #include<vector> #include<algorithm> #define ll long long using namespace std; int main(){ int n; cin>>n; vector<vector<int>> graph(n); int a,b; for(int i=0;i<n;i++){ cin>>a>>b; graph[a-1].push_back(b-1); graph[b-1].push_back(a-1); } if(n<=20){ int ans=1e9; for(int i=0;i<(1<<n);i++){ for(int j=0;j<n;j++){ int cnt=0; for(auto x:graph[j]){ if(((1<<x)&i)>0){ cnt++; } } if(cnt!=1) break; if(j==n-1){ cnt=0; for(int k=0;k<n;k++){ if(((1<<k)&i)>0) cnt++; } ans=min(ans,cnt); } } } if(ans==1e9) cout<<-1<<"\n"; else cout<<ans<<"\n"; return 0; } if(n%4==0) cout<<n/2; else cout<<-1; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...