Submission #683719

#TimeUsernameProblemLanguageResultExecution timeMemory
683719aSSSdLogičari (COCI21_logicari)C++14
20 / 110
131 ms3020 KiB
#include <bits/stdc++.h> using namespace std; #define in ({int x=0;int c=getchar(),n=0;for(;!isdigit(c);c=getchar()) n=(c=='-');for(;isdigit(c);c=getchar()) x=x*10+c-'0';n?-x:x;}) mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); int rnd(int l,int r) { return l+rng()%(r-l+1); } #define fasty ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0); #define forinc(x,a,b) for(int x=a;x<=b;x++) #define fordec(x,a,b) for(int x=a;x>=b;x--) #define forv(a,b) for(auto&a:b) #define fi first #define se second #define pb push_back #define ll long long #define mt make_tuple #define all(a) a.begin(),a.end() #define reset(f,x) memset(f,x,sizeof(f)) #define getbit(x,i) ((x>>(i))&1) #define batbit(x,i) (x|(1ll<<(i))) #define tatbit(x,i) (x&~(1<<(i))) #define gg exit(0); #define int long long #define ii pair<int,int> const int N = 1e5 + 100; int n; int cnt[22]; ii edge[N]; main() { fasty; cin >> n; forinc(i,1,n) { int u,v; cin >> u >> v; edge[i] = {u,v}; } if(n<=20) { int res=1e8; int lim=(1<<n)-1; forinc(mask , 0 , lim) { memset(cnt,0,sizeof cnt); forinc(i,1,n) { int u = edge[i].fi; int v = edge[i].se; if(getbit(mask , u-1)) cnt[v]++; if(getbit(mask,v-1)) cnt[u]++; } int ok=1; forinc(i,1,n) { if(cnt[i] != ok) { ok=0; break; } } int sl = __builtin_popcount(mask); if(ok) res = min(res , sl); } if(res>=1e8) { cout << -1; return 0; } cout << res; return 0; } if(n%4 == 0 ) { cout << n/2; return 0; } cout << -1; }

Compilation message (stderr)

Main.cpp:31:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   31 | main()
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...