Submission #1060574

#TimeUsernameProblemLanguageResultExecution timeMemory
1060574Szymon_PilipczukThe Xana coup (BOI21_xanadu)C++17
5 / 100
1058 ms7792 KiB
#include <iostream> #include <vector> #include <algorithm> using namespace std; int main() { int n; cin>>n; int o[n]; int ans = n+1; vector<int> tr[n]; int a,b; for(int i = 0;i<n-1;i++) { cin>>a>>b; a--;b--; tr[a].push_back(b); tr[b].push_back(a); } for(int i =0;i<n;i++) { cin>>o[i]; } for(int i = 0;i<(1<<n);i++) { int oc[n]; copy(o,o+n,oc); int ci = i; int q = 0; int counter = 0; while(ci>0) { if(ci%2 == 1) { counter++; oc[q] = (oc[q]+1)%2; for(int j = 0;j<size(tr[q]);j++) { oc[tr[q][j]]= (oc[tr[q][j]]+1)%2; } } q++; ci/=2; } bool win = true; for(int j = 0;j<n;j++) { if(oc[j] == 1) { win = false; } } if(i == 29) { } if(win) { ans = min(ans,counter); } } if (ans == n+1) { cout<<"impossible"; } else { cout<<ans; } }

Compilation message (stderr)

xanadu.cpp: In function 'int main()':
xanadu.cpp:38:32: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |                 for(int j = 0;j<size(tr[q]);j++)
      |                               ~^~~~~~~~~~~~
#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...