제출 #782894

#제출 시각아이디문제언어결과실행 시간메모리
782894makanhuliaThe Xana coup (BOI21_xanadu)C++17
0 / 100
1078 ms524288 KiB
#include<bits/stdc++.h> #define int long long using namespace std; const int MAX=1e9; int n; vector<vector<int>> adj; int cnt(int qu, int u, vector<int> c, int vis) { if(qu==n+1) return MAX; int sum=0; for(int p : c) sum+=p; if(sum==0) return 0; c[u]^=1; for(int p : adj[u]) c[p]^=1; int ret=MAX; for(int i=0; i<n; i++) { if(vis&(1 << i)) continue; ret=min(ret, 1+cnt(qu+1, i, c, vis^(1LL << i))); } return ret; } signed main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n; adj.resize(n); for(int i=1; i<n; i++) { int u, v; cin >> u >> v; --u; --v; adj[u].push_back(v); adj[v].push_back(u); } vector<int> c(n); for(int &p : c) cin >> p; int ans=MAX; for(int i=0; i<n; i++) { ans=min(ans, cnt(1, i, c, (1LL << i))); } if(ans>=MAX) cout << "impossible\n"; else cout << ans << '\n'; return 0; }

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

xanadu.cpp: In function 'long long int cnt(long long int, long long int, std::vector<long long int>, long long int)':
xanadu.cpp:9:3: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
    9 |   for(int p : c) sum+=p; if(sum==0) return 0;
      |   ^~~
xanadu.cpp:9:26: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
    9 |   for(int p : c) sum+=p; if(sum==0) 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...
#Verdict Execution timeMemoryGrader output
Fetching results...