QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#829500 | #8948. 报复社会 | 275307894a# | 20 | 3ms | 11888kb | C++14 | 1.6kb | 2024-12-24 10:28:19 | 2024-12-24 10:28:20 |
Judging History
answer
#include<bits/stdc++.h>
#define Gc() getchar()
#define Me(x,y) memset(x,y,sizeof(x))
#define Mc(x,y) memcpy(x,y,sizeof(x))
#define d(x,y) ((m)*(x-1)+(y))
#define R(n) (rnd()%(n)+1)
#define Pc(x) putchar(x)
#define LB lower_bound
#define UB upper_bound
#define fi first
#define se second
#define eb emplace_back
#define all(x) x.begin(),x.end()
using namespace std;using ll=long long;using db=double;using lb=long db;using ui=unsigned;using ull=unsigned long long;using pii=pair<int,int>;
const int N=5e5+5,M=(1<<20)+5,K=1000+5,mod=998244353,Mod=mod-1;const db eps=1e-9;const int INF=1e9+7;mt19937 rnd(28382);
#define Tp template<typename T>
#define Ts template<typename T,typename... Ar>
namespace Debug{
Tp void _debug(char* f,T t){cerr<<f<<'='<<t<<endl;}
Ts void _debug(char* f,T x,Ar... y){while(*f!=',') cerr<<*f++;cerr<<'='<<x<<",";_debug(f+1,y...);}
#ifdef LOCAL
#define gdb(...) _debug((char*)#__VA_ARGS__,__VA_ARGS__)
#else
#define gdb(...) void()
#endif
}using namespace Debug;
int n,p[N],col[N];
int vis[M];
int dfs(int msk){
gdb(msk);
if(~vis[msk]) return vis[msk];
int v=__builtin_popcount(msk);
if(v==n-1){
for(int i=1;i<=n;i++) if(~msk>>i-1&1) return vis[msk]=col[i];
}
v&=1;
for(int i=1;i<=n;i++) if(~msk>>i-1&1&&(i==1||msk>>p[i]-1&1)){
if(dfs(msk|(1<<i-1))==v) return vis[msk]=v;
}
return vis[msk]=v^1;
}
void Solve(){
scanf("%d",&n);
for(int i=2;i<=n;i++) scanf("%d",&p[i]);
for(int i=1;i<=n;i++) scanf("%d",&col[i]);
fill(vis,vis+(1<<n),-1);
puts(dfs(0)?"Bob":"Alice");
}
int main(){
int t=1;
scanf("%d",&t);
while(t--) Solve();
cerr<<clock()*1.0/CLOCKS_PER_SEC<<'\n';
}
詳細信息
Subtask #1:
score: 20
Accepted
Test #1:
score: 20
Accepted
time: 3ms
memory: 11616kb
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: 11012kb
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: 20
Accepted
time: 1ms
memory: 11732kb
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:
Alice
result:
ok "Alice"
Test #4:
score: 20
Accepted
time: 0ms
memory: 11364kb
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:
Alice
result:
ok "Alice"
Test #5:
score: 20
Accepted
time: 0ms
memory: 11240kb
input:
1 19 1 1 1 1 1 3 4 7 3 2 8 6 2 10 10 4 7 14 0 0 1 0 0 1 1 1 1 0 1 1 1 1 1 1 0 1 1
output:
Bob
result:
ok "Bob"
Test #6:
score: 20
Accepted
time: 2ms
memory: 11304kb
input:
1 20 1 2 3 4 5 3 7 3 3 3 2 2 2 1 15 16 16 1 1 0 0 0 0 0 1 0 0 0 0 0 1 1 1 0 0 0 1 1 1
output:
Alice
result:
ok "Alice"
Test #7:
score: 20
Accepted
time: 0ms
memory: 10580kb
input:
1 19 1 2 3 4 2 2 2 1 9 10 11 11 10 10 10 9 17 9 0 0 0 0 0 0 0 1 0 0 0 0 0 1 0 1 0 1 1
output:
Alice
result:
ok "Alice"
Test #8:
score: 20
Accepted
time: 0ms
memory: 9884kb
input:
1 20 1 2 3 4 4 3 3 2 9 10 9 9 9 9 9 2 2 2 2 0 0 0 0 0 1 0 1 0 0 1 0 0 0 0 1 1 1 1 1
output:
Alice
result:
ok "Alice"
Test #9:
score: 20
Accepted
time: 2ms
memory: 11456kb
input:
1 19 1 2 3 4 5 6 6 5 9 5 5 5 2 2 2 2 2 1 0 0 0 0 0 0 0 1 0 0 0 0 0 1 1 1 0 1 1
output:
Alice
result:
ok "Alice"
Test #10:
score: 20
Accepted
time: 0ms
memory: 11164kb
input:
1 20 1 2 2 2 3 1 6 4 3 2 8 2 5 7 3 3 10 10 15 0 1 1 0 0 0 1 0 1 1 1 0 0 0 0 1 1 0 0 0
output:
Alice
result:
ok "Alice"
Test #11:
score: 20
Accepted
time: 2ms
memory: 11708kb
input:
1 19 1 2 3 1 4 6 2 8 6 4 3 6 10 7 6 3 5 2 1 0 1 1 0 0 1 0 0 1 0 0 0 0 1 0 0 0 0
output:
Alice
result:
ok "Alice"
Test #12:
score: 20
Accepted
time: 0ms
memory: 11812kb
input:
1 20 1 1 3 2 2 4 4 6 5 1 5 2 2 10 13 11 6 5 11 1 1 0 0 0 1 0 1 1 0 0 0 0 1 0 0 1 0 0 0
output:
Alice
result:
ok "Alice"
Test #13:
score: 20
Accepted
time: 1ms
memory: 10880kb
input:
1 19 1 2 3 1 4 6 6 1 4 10 5 3 7 11 4 4 4 4 1 0 1 0 1 1 1 1 1 1 1 0 1 0 0 0 1 1 0
output:
Alice
result:
ok "Alice"
Test #14:
score: 20
Accepted
time: 2ms
memory: 10632kb
input:
1 20 1 2 3 4 5 5 3 8 3 3 3 3 2 14 15 2 2 2 2 0 0 0 0 0 0 1 0 0 0 0 0 1 0 0 1 1 1 0 1
output:
Alice
result:
ok "Alice"
Test #15:
score: 20
Accepted
time: 2ms
memory: 10192kb
input:
1 20 1 2 3 4 5 5 3 8 3 3 3 3 2 14 15 2 2 2 2 0 0 0 0 0 0 1 0 0 0 0 0 1 0 0 1 1 1 0 1
output:
Alice
result:
ok "Alice"
Test #16:
score: 20
Accepted
time: 0ms
memory: 10708kb
input:
1 19 1 2 3 4 5 3 3 3 3 2 1 12 13 12 15 15 15 1 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 1 1 1 1
output:
Bob
result:
ok "Bob"
Test #17:
score: 20
Accepted
time: 2ms
memory: 10456kb
input:
1 19 1 2 3 3 1 6 6 6 6 6 6 6 6 6 6 1 1 1 0 0 0 0 1 0 0 1 0 1 0 1 0 1 0 1 0 0 0
output:
Bob
result:
ok "Bob"
Test #18:
score: 20
Accepted
time: 2ms
memory: 10980kb
input:
1 20 1 2 3 4 5 5 5 4 4 4 4 4 3 3 2 2 1 1 1 0 0 0 0 0 1 1 1 0 0 0 0 1 1 1 0 0 0 0 0
output:
Bob
result:
ok "Bob"
Test #19:
score: 20
Accepted
time: 2ms
memory: 11860kb
input:
1 19 1 2 3 1 5 1 6 1 6 6 1 4 7 13 2 14 10 2 0 0 1 0 1 1 1 0 1 0 0 0 0 0 0 0 1 1 0
output:
Alice
result:
ok "Alice"
Test #20:
score: 20
Accepted
time: 2ms
memory: 10728kb
input:
1 20 1 1 3 1 2 5 7 6 8 3 8 4 9 4 12 7 17 7 16 0 1 1 0 1 1 0 1 1 1 0 1 0 0 1 0 1 1 1 1
output:
Bob
result:
ok "Bob"
Test #21:
score: 20
Accepted
time: 0ms
memory: 9960kb
input:
1 19 1 1 1 1 3 6 1 5 2 4 2 8 2 1 9 14 10 8 1 1 0 0 1 1 1 0 1 0 1 1 0 1 1 1 1 1 0
output:
Bob
result:
ok "Bob"
Test #22:
score: 20
Accepted
time: 2ms
memory: 11788kb
input:
1 20 1 2 3 4 4 4 3 8 8 8 8 3 3 3 3 3 2 2 2 0 0 0 0 0 0 1 0 0 1 0 1 1 1 1 1 1 0 0 1
output:
Bob
result:
ok "Bob"
Test #23:
score: 20
Accepted
time: 2ms
memory: 11044kb
input:
1 19 1 1 2 3 4 2 1 1 1 6 7 6 3 5 5 16 15 12 0 1 0 1 0 0 0 1 0 1 1 1 1 1 1 0 0 1 0
output:
Bob
result:
ok "Bob"
Test #24:
score: 20
Accepted
time: 0ms
memory: 11284kb
input:
1 20 1 2 3 4 4 4 4 3 9 9 3 3 2 2 2 1 1 1 1 0 0 0 0 0 0 0 0 0 1 1 0 1 1 0 1 1 1 0 1
output:
Alice
result:
ok "Alice"
Test #25:
score: 20
Accepted
time: 2ms
memory: 9964kb
input:
1 19 1 1 2 3 2 6 6 4 3 8 10 2 11 9 5 1 10 5 1 1 0 1 0 1 0 1 1 0 1 1 1 1 1 0 0 0 0
output:
Bob
result:
ok "Bob"
Test #26:
score: 20
Accepted
time: 2ms
memory: 11868kb
input:
1 20 1 2 2 4 4 4 1 6 4 10 9 6 2 2 4 5 9 12 8 0 1 0 1 0 1 0 0 1 1 1 1 0 0 1 1 0 1 0 1
output:
Alice
result:
ok "Alice"
Test #27:
score: 20
Accepted
time: 1ms
memory: 11000kb
input:
1 19 1 1 1 3 5 2 3 2 1 7 6 11 12 9 13 7 16 15 0 0 1 0 1 1 1 0 0 0 1 0 1 0 1 0 0 0 1
output:
Alice
result:
ok "Alice"
Test #28:
score: 20
Accepted
time: 2ms
memory: 11008kb
input:
1 20 1 2 3 2 4 4 2 7 2 5 8 8 1 9 1 3 3 9 5 0 0 1 0 1 1 1 1 1 1 1 1 1 0 0 0 0 1 1 0
output:
Alice
result:
ok "Alice"
Test #29:
score: 20
Accepted
time: 0ms
memory: 11372kb
input:
1 19 1 2 3 4 5 6 2 8 2 2 2 2 1 14 15 16 15 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 1
output:
Alice
result:
ok "Alice"
Test #30:
score: 20
Accepted
time: 0ms
memory: 11600kb
input:
1 19 1 2 3 4 5 6 2 8 2 2 2 2 1 14 15 16 15 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 1
output:
Alice
result:
ok "Alice"
Test #31:
score: 20
Accepted
time: 2ms
memory: 10872kb
input:
1 19 1 2 2 2 1 6 7 8 8 8 8 8 6 6 1 1 1 1 0 0 1 1 1 0 0 0 0 0 1 0 1 1 1 0 0 0 0
output:
Alice
result:
ok "Alice"
Test #32:
score: 20
Accepted
time: 2ms
memory: 10508kb
input:
1 20 1 2 3 4 5 6 5 3 9 9 9 3 2 2 2 2 2 1 1 0 0 0 0 0 0 0 1 0 0 0 0 1 1 1 1 1 1 0 1
output:
Alice
result:
ok "Alice"
Test #33:
score: 20
Accepted
time: 0ms
memory: 11888kb
input:
1 19 1 2 2 2 2 1 7 8 9 8 8 7 13 7 7 1 1 1 0 0 0 0 0 1 0 0 0 0 1 1 0 0 1 1 1 0 1
output:
Bob
result:
ok "Bob"
Test #34:
score: 20
Accepted
time: 0ms
memory: 11796kb
input:
1 20 1 2 1 4 5 6 5 4 9 10 10 9 9 9 9 9 4 1 1 0 0 0 0 0 0 1 0 0 0 0 1 0 0 1 0 1 0 1 1
output:
Alice
result:
ok "Alice"
Test #35:
score: 20
Accepted
time: 2ms
memory: 11788kb
input:
1 19 1 2 2 4 2 1 5 6 1 5 4 12 9 2 9 9 12 4 1 0 1 1 1 1 1 0 0 1 1 1 1 0 1 0 1 0 1
output:
Bob
result:
ok "Bob"
Test #36:
score: 20
Accepted
time: 2ms
memory: 10240kb
input:
1 20 1 2 3 4 5 4 3 3 2 2 2 2 2 2 2 2 2 2 2 0 0 0 0 0 0 1 0 1 1 0 1 0 1 0 1 0 1 0 1
output:
Alice
result:
ok "Alice"
Test #37:
score: 20
Accepted
time: 0ms
memory: 11744kb
input:
1 19 1 2 3 4 2 6 7 6 6 2 2 1 13 14 14 13 13 1 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 1 1 1
output:
Alice
result:
ok "Alice"
Test #38:
score: 20
Accepted
time: 0ms
memory: 10924kb
input:
1 20 1 2 3 4 1 3 7 6 5 8 8 5 11 12 9 9 8 14 6 1 1 0 1 1 1 0 1 1 1 0 0 0 0 1 1 0 1 1 0
output:
Bob
result:
ok "Bob"
Test #39:
score: 20
Accepted
time: 0ms
memory: 10612kb
input:
1 19 1 2 3 4 4 4 4 3 3 3 3 2 2 2 2 1 1 1 0 0 0 0 0 1 0 1 1 1 0 1 0 0 0 0 1 0 1
output:
Bob
result:
ok "Bob"
Test #40:
score: 20
Accepted
time: 2ms
memory: 10116kb
input:
1 20 1 2 3 4 3 6 7 3 2 10 2 2 2 2 2 1 1 1 1 0 0 0 0 1 0 0 1 1 0 1 0 0 0 0 0 0 0 0 0
output:
Bob
result:
ok "Bob"
Test #41:
score: 20
Accepted
time: 0ms
memory: 11368kb
input:
1 19 1 2 3 3 3 3 3 3 3 3 3 2 13 2 2 1 17 1 0 0 0 0 0 1 0 1 0 1 0 1 0 0 1 1 0 0 1
output:
Alice
result:
ok "Alice"
Test #42:
score: 20
Accepted
time: 1ms
memory: 11072kb
input:
1 20 1 2 3 2 1 6 6 6 4 7 4 2 9 13 2 11 5 14 4 0 1 0 0 0 1 1 1 1 0 0 1 0 1 0 1 1 1 1 0
output:
Bob
result:
ok "Bob"
Test #43:
score: 20
Accepted
time: 1ms
memory: 11676kb
input:
1 19 1 1 3 3 3 4 1 5 5 2 5 11 4 4 4 6 17 17 1 0 1 0 0 1 0 0 1 1 0 1 1 0 0 1 0 0 1
output:
Bob
result:
ok "Bob"
Test #44:
score: 20
Accepted
time: 2ms
memory: 10780kb
input:
1 20 1 2 3 4 5 5 5 4 3 3 3 2 13 13 2 1 1 1 1 0 0 0 0 0 0 0 1 1 1 0 1 0 0 1 1 0 1 0 1
output:
Alice
result:
ok "Alice"
Test #45:
score: 20
Accepted
time: 1ms
memory: 10944kb
input:
1 19 1 1 2 1 5 1 6 5 7 5 1 8 9 4 4 8 7 17 0 1 1 0 0 1 0 1 0 1 0 0 0 0 1 0 0 1 1
output:
Bob
result:
ok "Bob"
Test #46:
score: 20
Accepted
time: 1ms
memory: 10684kb
input:
1 20 1 2 1 2 4 2 7 4 5 6 8 6 5 3 2 1 13 10 8 0 0 0 1 0 1 1 1 1 1 1 0 1 1 0 0 1 0 1 0
output:
Alice
result:
ok "Alice"
Test #47:
score: 20
Accepted
time: 0ms
memory: 11316kb
input:
1 19 1 2 2 4 4 4 3 3 6 4 4 4 10 3 6 7 17 4 0 0 1 1 0 0 1 0 1 0 0 0 1 0 1 1 0 1 0
output:
Alice
result:
ok "Alice"
Test #48:
score: 20
Accepted
time: 0ms
memory: 11656kb
input:
1 20 1 2 3 4 4 4 4 3 9 9 9 3 3 3 3 1 1 1 1 0 0 0 0 0 1 0 1 0 1 0 1 1 1 1 1 0 0 0 0
output:
Bob
result:
ok "Bob"
Test #49:
score: 20
Accepted
time: 2ms
memory: 10656kb
input:
1 19 1 2 3 4 5 4 4 4 3 3 3 3 2 1 1 1 1 1 0 0 0 0 0 0 0 0 1 1 1 0 1 1 1 0 1 0 1
output:
Alice
result:
ok "Alice"
Subtask #2:
score: 0
Runtime Error
Test #50:
score: 0
Runtime Error
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:
result:
Subtask #3:
score: 0
Runtime Error
Test #73:
score: 0
Runtime Error
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:
result:
Subtask #4:
score: 0
Skipped
Dependency #1:
100%
Accepted
Dependency #2:
0%