제출 #889197

#제출 시각아이디문제언어결과실행 시간메모리
889197AloraLogičari (COCI21_logicari)C++17
20 / 110
30 ms7004 KiB
#include <bits/stdc++.h> #define Alora "cownav" #define fi(i,a,b) for(int i = a; i <= b; i++) #define fid(i,a,b) for(int i = a; i >= b; i--) #define ll long long #define f first #define se second #define pii pair<int, int> #define getbit(i, j) ((i >> j) & 1) #define all(v) v.begin(), v.end() #define pb push_back #define maxn 100005 const int M = 1e9 + 7; using namespace std; int n, xd[maxn], res = 1e9, ok, ok1 = 1; vector <int> g[maxn]; void sub1(){ if(n % 4 == 0) cout << n/2; else cout << -1; exit(0); } void sub2(){ fi(tt, 1, (1 << n) - 1){ int cnt = __builtin_popcount(tt); fi(i, 0, n - 1) xd[i + 1] = getbit(tt, i); ok = 1; fi(u, 1, n){ int sl = 0; for(auto v: g[u]) sl += xd[v]; if(sl != 1) {ok = 0; break;} } if(ok) res = min(res, cnt); } if(res == 1e9) cout << -1; else cout << res; exit(0); } int main(){ ios_base::sync_with_stdio(0); cin.tie(NULL); if(fopen(Alora".inp", "r")){ freopen(Alora".inp", "r", stdin); freopen(Alora".out", "w", stdout);} cin >> n; fi(i, 1, n){ int u, v; cin >> u >> v; g[u].pb(v); g[v].pb(u); } fi(i, 1, n) if(g[i].size() != 2) {ok1 = 0; break;} if(ok1) sub1(); if(n <= 20) sub2(); return 0; }

컴파일 시 표준 에러 (stderr) 메시지

Main.cpp: In function 'int main()':
Main.cpp:44:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   44 |     freopen(Alora".inp", "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:45:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   45 |     freopen(Alora".out", "w", stdout);}
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...