Submission #1128487

#TimeUsernameProblemLanguageResultExecution timeMemory
1128487Alihan_8The Xana coup (BOI21_xanadu)C++20
10 / 100
67 ms6216 KiB
#include <bits/stdc++.h> using namespace std; signed main(){ int n; cin >> n; vector <vector<int>> adj(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> a(n); for ( auto &u: a ) cin >> u; int cnt = 0; for ( int i = 0; i + 1 < n; i++ ){ if ( a[i] != 0 ){ cnt += 1; a[i] ^= 1, a[i + 1] ^= 1; if ( i + 2 < n ) a[i + 2] ^= 1; } } if ( a[n - 1] != 0 ) return cout << "impossible\n", 0; cout << cnt << '\n'; }
#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...