# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1060576 | Szymon_Pilipczuk | The Xana coup (BOI21_xanadu) | C++17 | 1080 ms | 6480 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 <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(long long i = 0;i<(1<<n);i++)
{
int oc[n];
copy(o,o+n,oc);
long long 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)
# | 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... |