QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#570427#8948. 报复社会hewanying0 4ms21268kbC++14705b2024-09-17 15:47:152024-09-17 15:47:20

Judging History

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

  • [2024-09-17 15:47:20]
  • 评测
  • 测评结果:0
  • 用时:4ms
  • 内存:21268kb
  • [2024-09-17 15:47:15]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define pb push_back

const int N=5e5+5;
int n,sz[N],f[N],col[N];
vector<int> G[N];

void dfs(int u){
  sz[u]=1;
  if(!(int)G[u].size()) return f[u]=col[u]?-1:1,void();
  for(auto v:G[u]) dfs(v),f[u]+=f[v],sz[u]+=sz[v];
  if(f[u]>0||(!f[u]&&!(n&1))) ++f[u];
  else --f[u]; 
}

void SOLVE(){
  cin>>n;
  for(int i=1;i<=n;i++) f[i]=sz[i]=col[i]=0,G[i].clear();
  for(int i=2,x;i<=n;i++) cin>>x,G[x].pb(i);
  for(int i=1;i<=n;i++) cin>>col[i];
  dfs(1);
  if(f[1]>0) cout<<"Alice\n";
  else cout<<"Bob\n";
}

int main(){
  ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
  int T,_;cin>>T>>_;
  while(_--) SOLVE();
  return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 20264kb

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
Bob
Bob
Bob
Bob
Bob
Bob
Bob
Bob
Bob
Bob
Bob
Bob
Bob
Bob
Bob
Bob
Bob
Bob

result:

wrong answer Participant output contains extra tokens

Subtask #2:

score: 0
Wrong Answer

Test #50:

score: 0
Wrong Answer
time: 4ms
memory: 21236kb

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
Bob
Bob
Bob
Bob
Bob
Bob
Bob
Bob
Bob
Bob
Bob
Bob
Bob
Bob
Bob
Alice
Alice
Alice
Alice
Alice
Alice
Alice
Alice
Alice
Alice
Alice
Alice
Alice
Alice
Bob
Bob
Alice
Alice
Alice
Alice
Bob
Bob
Bob
Bob
Bob
Alice
Alice
Bob
Bob
Alice
Bob
Bob
Alice

result:

wrong answer 2nd words differ - expected: 'Alice', found: 'Bob'

Subtask #3:

score: 0
Wrong Answer

Test #73:

score: 0
Wrong Answer
time: 0ms
memory: 21268kb

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:

Bob
Bob
Bob
Bob
Bob
Bob
Alice
Alice
Alice
Alice
Alice
Alice
Alice
Alice
Alice
Alice
Alice
Alice
Alice
Alice
Alice
Alice
Bob
Bob
Bob
Bob
Bob
Bob
Bob
Alice
Alice
Alice
Alice
Alice
Alice
Alice
Alice
Alice
Alice
Bob
Bob
Alice
Bob
Bob
Bob
Bob
Bob
Bob
Bob
Bob

result:

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

Subtask #4:

score: 0
Skipped

Dependency #1:

0%