# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1056535 | SzymonKrzywda | The Xana coup (BOI21_xanadu) | C++17 | 77 ms | 7604 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n,m,a,b;
cin >> n;
vector<vector<int>> graf(n, vector<int>(0));
vector<int> tablica(n,0);
for (int i=0; i<n-1; i++){
cin >> a >> b;
a--;b--;
graf[a].push_back(b);
graf[b].push_back(a);
}
for (int i=0; i<n; i++) cin >> tablica[i];
int wynik=0;
for (int i=1; i<n; i++){
if (tablica[i-1]){
tablica[i-1] = 0;
tablica[i] = (tablica[i]+1)%2;
if (i<(n-1)) tablica[i+1] = (tablica[i+1]+1)%2;
wynik++;
}
}
bool git=true;
for (int i=0; i<n; i++) if(tablica[i]) git=false;
if (git) cout << wynik << endl;
else cout << "impossible\n";
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |