Submission #742207

#TimeUsernameProblemLanguageResultExecution timeMemory
742207sword060Logičari (COCI21_logicari)C++17
20 / 110
57 ms340 KiB
#include <bits/stdc++.h> using namespace std; int main(){ ios::sync_with_stdio(0);cin.tie(0); int x; cin>>x; if(x>20){ cout<<(x%4?-1:x/2); return 0; } vector<int>v[x]; for(int i=1;i<=x;i++){ int l,r;cin>>l>>r; l--;r--; v[l].push_back(r); v[r].push_back(l); } int ans=1e9; for(int i=1;i<(1<<x);i++){ bool f=1; for(int j=0;j<x;j++){ int cnt=0; for(auto c:v[j]) if(i&(1<<c))cnt++; f&=(cnt==1); } if(f) ans=min(ans,__builtin_popcount(i)); } cout<<(ans==1e9?-1:ans); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...