B 树上小游戏 王潇乐
You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.
#include<bits/stdc++.h>
#define pr pair<int,int>
#define eps 1e-7
#define vt vector<int>
using namespace std;
inline int read()
{
int x=0,f=1;char ch=getchar();
while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}
return x*f;
}
const int N=(1<<15)+1;
int l[N],r[N],c[N];
bool dfs(vt now,int ty,int num)
{
if(!now.size())
return !((num&1)^ty);
vt nowl,nowr,nowlr;
int numl=num,numr=num,numlr=num;
for(int x:now)
{
if(l[x])
{
nowl.push_back(l[x]);
nowlr.push_back(l[x]);
numl+=c[l[x]];
numlr+=c[l[x]];
}
if(r[x])
{
nowr.push_back(r[x]);
nowlr.push_back(r[x]);
numr+=c[r[x]];
numlr+=c[r[x]];
}
}
return !dfs(nowl,ty^1,numl)||!dfs(nowr,ty^1,numr)||!dfs(nowlr,ty^1,numlr);
}
int n;
int main()
{
n=read();
for(int i=1;i<=n;i++)
l[i]=read(),r[i]=read(),c[i]=read();
for(int i=1;i<=n;i++)
{
vt now;
now.push_back(i);
puts(dfs(now,0,c[i])?"Alice":"Bob");
}
return 0;
}
7.31日竞赛3班造数据
- Status
- Done
- Rule
- IOI
- Problem
- 8
- Start at
- 2025-7-31 18:00
- End at
- 2025-7-31 21:00
- Duration
- 3 hour(s)
- Host
- Partic.
- 8