QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#572150#8948. 报复社会yhddd0 13ms7816kbC++201.3kb2024-09-18 12:38:362024-09-18 12:38:37

Judging History

你现在查看的是最新测评结果

  • [2024-09-18 12:38:37]
  • 评测
  • 测评结果:0
  • 用时:13ms
  • 内存:7816kb
  • [2024-09-18 12:38:36]
  • 提交

answer

#include<bits/stdc++.h>
#define int long long
#define mod 998244353ll
#define pii pair<int,int>
#define fi first
#define se second
#define mems(x,y) memset(x,y,sizeof(x))
#define pb push_back
using namespace std;
const int maxn=200010;
const int inf=1e18;
inline int read(){
	int x=0,f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=(x<<3)+(x<<1)+(ch-48);ch=getchar();}
	return x*f;
}
bool Mbe;

int n,a[maxn];
int head[maxn],tot;
struct nd{
	int nxt,to;
}e[maxn];
void add(int u,int v){e[++tot]={head[u],v};head[u]=tot;}
void dfs(int u){
	int num0=0,num1=0;
	for(int i=head[u];i;i=e[i].nxt){
		int v=e[i].to;dfs(v);
		num0+=1-a[v],num1+=a[v];
	}
	if(num0>num1)a[u]=0;
	if(num0==num1)a[u]=n&1;
	if(num0<num1)a[u]=1;
}
void work(){
	n=read();
	for(int i=1;i<=n;i++)head[i]=0;tot=0;
	for(int i=2;i<=n;i++){
		int u=read();
		add(u,i);
	}
	for(int i=1;i<=n;i++)a[i]=read();
	dfs(1);
	if(!a[1])puts("Alice");
	else puts("Bob");
}


// \
444

bool Med;
int T;
signed main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	
//	ios::sync_with_stdio(0);
//	cin.tie(0);cout.tie(0);
	
//	cerr<<(&Mbe-&Med)/1048576.0<<" MB\n";
	
	T=read();
	while(T--)work();
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 20
Accepted
time: 1ms
memory: 7816kb

input:

1
19
1 2 3 3 2 6 7 7 6 6 6 2 2 2 1 1 1 1
0 0 0 0 0 0 0 1 1 0 0 1 1 1 1 0 0 0 0

output:

Bob

result:

ok "Bob"

Test #2:

score: 20
Accepted
time: 1ms
memory: 7792kb

input:

1
20
1 1 3 2 4 1 4 4 1 7 1 6 3 12 6 12 8 5 7
1 0 1 1 1 0 0 1 1 0 0 1 0 1 0 1 0 0 0 1

output:

Alice

result:

ok "Alice"

Test #3:

score: 0
Wrong Answer
time: 1ms
memory: 5664kb

input:

1
19
1 2 3 4 5 1 1 8 8 3 7 3 13 3 15 10 2 17
0 0 1 0 0 0 0 1 1 1 1 0 0 0 0 0 0 1 0

output:

Bob

result:

wrong answer 1st words differ - expected: 'Alice', found: 'Bob'

Subtask #2:

score: 0
Wrong Answer

Test #50:

score: 0
Wrong Answer
time: 13ms
memory: 7672kb

input:

10000
49
1 2 2 1 5 5 5 5 5 5 1 12 12 12 12 12 12 1 19 19 19 19 19 19 19 1 27 27 1 1 31 1 33 33 33 33 33 33 33 1 1 1 1 1 1 1 1 1
0 0 0 0 1 1 1 1 1 1 1 1 1 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 1 0 0 1 0 1 0 1 1 1 1 1 1 1 1 1 1
50
1 2 2 2 2 2 1 8 8 8 1 12 1 1 15 15 15 15 1 1 21 21 21 21 1 26 1 1 29 29...

output:

Bob
Alice
Alice
Bob
Bob
Alice
Bob
Bob
Alice
Alice
Bob
Alice
Bob
Bob
Alice
Alice
Bob
Bob
Alice
Bob
Bob
Alice
Alice
Alice
Bob
Bob
Alice
Alice
Bob
Bob
Alice
Alice
Bob
Bob
Alice
Alice
Bob
Bob
Alice
Alice
Alice
Alice
Bob
Alice
Bob
Bob
Alice
Bob
Bob
Bob
Alice
Bob
Alice
Bob
Alice
Alice
Alice
Alice
Alice
Al...

result:

wrong answer 10th words differ - expected: 'Bob', found: 'Alice'

Subtask #3:

score: 0
Wrong Answer

Test #73:

score: 0
Wrong Answer
time: 13ms
memory: 7788kb

input:

10000
50
1 2 1 4 5 6 5 4 9 4 11 4 1 14 15 16 16 16 15 14 21 21 21 14 14 14 14 14 1 30 30 30 30 30 1 36 37 37 37 36 41 41 41 36 1 1 1 1 1
0 0 0 0 0 0 0 0 0 1 0 0 1 0 0 0 0 0 1 1 0 1 1 1 1 1 1 1 1 0 1 0 1 0 1 0 0 0 0 1 0 0 0 0 1 1 0 1 0 1
50
1 2 3 4 5 4 7 8 7 4 11 12 11 14 11 16 11 18 11 4 21 4 4 4 3 ...

output:

Alice
Alice
Alice
Alice
Alice
Alice
Alice
Alice
Alice
Alice
Alice
Alice
Alice
Alice
Alice
Alice
Alice
Alice
Alice
Alice
Alice
Alice
Alice
Alice
Alice
Alice
Alice
Alice
Alice
Alice
Alice
Alice
Alice
Alice
Alice
Alice
Alice
Alice
Alice
Alice
Alice
Alice
Alice
Alice
Alice
Alice
Alice
Alice
Alice
Alice
...

result:

wrong answer 5th words differ - expected: 'Bob', found: 'Alice'

Subtask #4:

score: 0
Skipped

Dependency #1:

0%