Submission #1056673

#TimeUsernameProblemLanguageResultExecution timeMemory
1056673kachim2The Xana coup (BOI21_xanadu)C++17
0 / 100
1083 ms205172 KiB
#include<bits/stdc++.h> using namespace std; vector<vector<int>> tree; int N; int bst = INT_MAX; void x(vector<bool> lit, int n, int cnt){ bool gud = 0; for(int i = 1; i <= N; i++) if(lit[i]) gud = 1; if(!gud){ bst = min(bst, cnt); } if(n==N+1) return; x(lit, n+1, cnt); lit[n] = !lit[n] ; for(auto i : tree[n]) lit[i] = !lit[i]; x(lit, n+1, cnt+1); } int main(){ int n; cin >> n; N=n; tree.resize(n+1); vector<bool> lit(n+1); for(int i = 0; i < n-1; i++){ int a, b; cin >> a >> b; tree[a].push_back(b); tree[b].push_back(a); } for(int i = 1; i <= n; i++){ int x;cin >> x; lit[i] = x; } x(lit, 1, 0); if(bst == INT_MAX) cout << "imposible"; else cout << bst; }
#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...