Submission #1272006

#TimeUsernameProblemLanguageResultExecution timeMemory
1272006oswaldzzLogičari (COCI21_logicari)C++20
10 / 110
11 ms1204 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define nl endl #define hehe ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL) ; // const int mod = 998244353; const int mod = 1e9+7; const int M = 2e5+5; int count(int x){ int c = 0; while(x){ x &= (x - 1); c++; } return c; } void solve(){ int n; cin >> n; int a[n+5] = {}; for(int i = 1; i<=n; i++){ int x,y; cin >> x >> y; a[x]|= 1ll << (y-1); a[y]|= 1ll << (x-1); } int tmp = LLONG_MAX; for(int i = 0; i< (1 << n); i++) { bool ok = true; for (int j = 1; j<=n; j++) { int t = a[j] & i; int cnt = count(t); if(cnt!=1){ ok = false; break; } } if(ok){ int cur = count(i); if(cur < tmp) tmp = cur; } } if(tmp == LLONG_MAX) cout << "-1" << nl; else cout << tmp << nl; } signed main(){ hehe // int t; cin >> t; int t = 1; while(t--){ solve(); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...