# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
782929 | christinelynn | The Xana coup (BOI21_xanadu) | C++17 | 1096 ms | 7252 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>
#define LL long long
using namespace std;
int main()
{
LL n;
scanf("%lld",&n);
vector<LL>adj[n+5];
for(LL a=1;a<=n-1;a++)
{
LL x,y;
scanf("%lld %lld",&x,&y);
x--,y--;
adj[x].push_back(y);
adj[y].push_back(x);
}
LL deg[n+5];
for(LL a=0;a<n;a++)scanf("%lld",°[a]);
LL minn=1e9;
for(LL a=0;a<(1LL<<n);a++)
{
LL temp[n+5];
for(LL b=0;b<n;b++)temp[b]=deg[b];
// if(a==4)cout<<"a="<<a<<endl;
for(LL x=0;x<n;x++)
{
if(a&(1<<x))
{
// cout<<temp[x]<<endl;
temp[x]=temp[x]^1;
// cout<<temp[x]<<endl;
for(LL jeje:adj[x])
{
temp[jeje]=temp[jeje]^1;
// if(a==4)printf("temp[%lld]=%lld\n",jeje,temp[jeje]);
}
// if(a==4)
// {
// printf("x = ");
// cout<<x<<endl;
// for(LL b=0;b<n;b++)cout<<deg[b]<<" ";
// cout<<endl;
// }
}
}
bool jawab=1;
for(LL b=0;b<n;b++)
{
if(temp[b]==1)
{
jawab=0;
break;
}
}
if(jawab)
{
// printf("a = %lld\n",a);
if(__builtin_popcount(a)<minn)
{
minn=__builtin_popcount(a);
}
}
}
if(minn==1e9)cout<<"impossible"<<endl;
else cout<<minn<<endl;
}
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... |