Submission #540338

#TimeUsernameProblemLanguageResultExecution timeMemory
540338BadPenaltyLogičari (COCI21_logicari)C++14
10 / 110
111 ms468 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define F first #define S second #define pb push_back #define endl '\n' #define all(x) x.begin(),x.end() #define yes cout<<"Yes"<<endl #define no cout<<"No"<<endl const int N = 1000,mod = 1e9+7; vector<int>adj[N]; bool blue[N]; int main() { ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); int n; cin>>n; for(int i = 0;i<n;i++) { int a,b; cin>>a>>b; adj[a].pb(b); adj[b].pb(a); } int ans = 1e9; for(int mask = 0;mask< (1<<n) ;mask++) { for(int i = 1;i<=n;i++)blue[i] = 0; int cur = 0; bool tr = 1; for(int i = 0;i<n;i++) { if(mask&(1<<i)) blue[i+1] = 1,cur++; } for(int i = 1;i<=n;i++) { int cnt = 0; for(auto u:adj[i]) cnt+=blue[u]; if(cnt!=1) tr = 0; } if(tr) ans = min(ans,cur); } if(ans==1e9) cout<<-1<<endl; else cout<<ans<<endl; 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...