Submission #1056535

#TimeUsernameProblemLanguageResultExecution timeMemory
1056535SzymonKrzywdaThe Xana coup (BOI21_xanadu)C++17
10 / 100
77 ms7604 KiB
#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)

xanadu.cpp: In function 'int main()':
xanadu.cpp:8:11: warning: unused variable 'm' [-Wunused-variable]
    8 |     int n,m,a,b;
      |           ^
#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...