QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#572999#8948. 报复社会treeiii0 10ms9872kbC++141.6kb2024-09-18 17:02:022024-09-18 17:02:02

Judging History

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

  • [2024-09-18 17:02:02]
  • 评测
  • 测评结果:0
  • 用时:10ms
  • 内存:9872kb
  • [2024-09-18 17:02:02]
  • 提交

answer

#include<bits/stdc++.h>
#define int long long
#define _int __int128
#define y1 _
using namespace std;

static char buf[1000000],*p1=buf,*p2=buf;

inline int read(){
	char c=getchar();
	int res=0,f=1;
	while(c<'0'||c>'9'){
		if(c=='-')f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9'){
		res=res*10+c-'0';
		c=getchar();
	}
	return res*f;
}

inline void write(int x){
	static char buf[20];
	static int len=-1;
	if(x<0){
		putchar('-');
		x=-x;
	}
	do{
		buf[++len]=x%10;
		x/=10;
	}
	while(x);
	while(len>=0){
		putchar(buf[len--]+48);
	}
}

const int maxn=300005;
const int maxm=510;
const int inf=1e18;
const int bas=100;
const int mod=1e9+7;
const double eps=1e-4;

int n,a[maxn];
int head[maxn],tot;

int dp[maxn];

struct edge{
	int nxt,to;
}e[maxn];
void add(int u,int v){
	e[++tot]={head[u],v};
	head[u]=tot;
}

void dfs(int u){
	if(!head[u]){
		dp[u]=dp[u]*2-1;
		return ;
	}
	dp[u]=0;
	for(int i=head[u];i;i=e[i].nxt){
		int v=e[i].to;dfs(v);
		dp[u]+=dp[v];
	}
	if(a[u]>0){
		dp[u]++;
	}
	else if(a[u]<0){
		dp[u]--;
	}
	else{
		dp[u]=(n&1)?1:-1;
	}
}

void solve(){
	n=read();
	for(int i=1;i<=n;i++){
		head[i]=0;
		dp[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();
		dp[i]=a[i];
	}
	dfs(1);
	if(dp[1]<=0){
		puts("Alice");
	}
	else{
		puts("Bob");
	}
	return ;
}

signed main(){
	//	freopen("puxi.in","r",stdin);
	//	freopen("puxi.out","w",stdout);
	int T=1;
		T=read();
	while(T--){
		solve();
	}
	return 0;
}

詳細信息

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 20
Accepted
time: 2ms
memory: 9872kb

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: 2ms
memory: 9744kb

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: 2ms
memory: 9796kb

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: 10ms
memory: 9800kb

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: 10ms
memory: 9736kb

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%