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>
#define int long long
using namespace std;
signed main() {
int n;
cin >> n;
vector <pair <int, int> > v(n);
for (int i = 0; i < n - 1; i++) {
cin >> v[i].first >> v[i].second;
}
int cnt0 = 0, cnt1 = 0;
vector <int> a(n);
for (int i = 0; i < n; i++) {
cin >> a[i];
if (a[i] == 0) {
cnt0++;
}
else {
cnt1++;
}
}
if (n % 2 == 1) {
if (cnt1 == 1) {
cout << "impossible\n";
}
else if (cnt1 % 2 == 1) {
cout << n - 1 << "\n";
}
else {
cout << "impossible\n";
}
}
else {
if (cnt0 % 2 == 0) {
cout << n - 1 << "\n";
}
else {
cout << "impossible\n";
}
}
}
# | 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... |