QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#199312 | #4896. Alice、Bob 与 DFS | AFewSuns | 0 | 3ms | 13396kb | C++14 | 2.5kb | 2023-10-04 08:06:09 | 2023-10-04 08:06:10 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
namespace my_std{
#define ll long long
#define bl bool
ll my_pow(ll a,ll b,ll mod){
ll res=1;
if(!b) return 1;
while(b){
if(b&1) res=(res*a)%mod;
a=(a*a)%mod;
b>>=1;
}
return res;
}
ll qpow(ll a,ll b){
ll res=1;
if(!b) return 1;
while(b){
if(b&1) res*=a;
a*=a;
b>>=1;
}
return res;
}
#define db double
#define pf printf
#define pc putchar
#define fr(i,x,y) for(register ll i=(x);i<=(y);i++)
#define pfr(i,x,y) for(register ll i=(x);i>=(y);i--)
#define go(u) for(ll i=head[u];i;i=e[i].nxt)
#define enter pc('\n')
#define space pc(' ')
#define fir first
#define sec second
#define MP make_pair
#define il inline
#define inf 8e18
#define random(x) rand()*rand()%(x)
#define inv(a,mod) my_pow((a),(mod-2),(mod))
il ll read(){
ll sum=0,f=1;
char ch=0;
while(!isdigit(ch)){
if(ch=='-') f=-1;
ch=getchar();
}
while(isdigit(ch)){
sum=sum*10+(ch^48);
ch=getchar();
}
return sum*f;
}
il void write(ll x){
if(x<0){
x=-x;
pc('-');
}
if(x>9) write(x/10);
pc(x%10+'0');
}
il void writeln(ll x){
write(x);
enter;
}
il void writesp(ll x){
write(x);
space;
}
}
using namespace my_std;
vector<ll> vec[200020],V;
ll n,q,col[200020],f[200020][4],tree[200020],ans=0;
il ll lowbit(ll x){
return x&(-x);
}
il void mdf(ll x,ll v){
while(x<=n){
tree[x]+=v;
x+=lowbit(x);
}
}
ll query(ll k){
k--;
ll x=0;
pfr(i,18,0){
if((x|(1ll<<i))<=n&&((1ll<<i)-tree[x+(1ll<<i)])<=k){
k-=(1ll<<i)-tree[x+(1ll<<i)];
x|=1ll<<i;
}
}
return x+1;
}
il void solve(ll x){
if(!col[x]||vec[x].empty()){
fr(o,0,3){
ll now=o;
fr(i,0,(ll)vec[x].size()-1){
ll tmp=f[vec[x][i]][now];
if(tmp<2) now|=1ll<<tmp;
else{
tmp=query(tmp-1)+1;
mdf(tmp-1,1);
V.push_back(tmp-1);
}
}
if(now<3) f[x][o]=now&1;
else f[x][o]=query(1)+1;
fr(i,0,(ll)V.size()-1) mdf(V[i],-1);
V.clear();
}
}
else{
fr(o,0,3){
ll now=o;
fr(i,0,(ll)vec[x].size()-1){
ll tmp=f[vec[x][i]][now];
now=(bl)tmp+1;
}
f[x][o]=now&1;
}
}
}
int main(){
n=read();
fr(i,1,n) col[i]=read();
fr(i,1,n){
ll m=read();
while(m--){
ll x=read();
vec[i].push_back(x);
}
reverse(vec[i].begin(),vec[i].end());
}
pfr(i,n,1) solve(i);
q=read();
while(q--){
ll x=read();
ans^=f[x][0];
}
if(ans) pf("Alice");
else pf("Bob");
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 5
Accepted
time: 0ms
memory: 13260kb
input:
1000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...
output:
Alice
result:
ok "Alice"
Test #2:
score: -5
Wrong Answer
time: 0ms
memory: 12116kb
input:
1000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...
output:
Alice
result:
wrong answer 1st words differ - expected: 'Bob', found: 'Alice'
Subtask #2:
score: 0
Wrong Answer
Test #18:
score: 15
Accepted
time: 0ms
memory: 11932kb
input:
7 0 0 1 1 0 1 1 1 2 2 3 4 0 2 5 6 0 1 7 0 1 1
output:
Bob
result:
ok "Bob"
Test #19:
score: -15
Wrong Answer
time: 2ms
memory: 13260kb
input:
6 0 1 0 0 1 0 2 2 6 3 3 4 5 0 0 0 0 1 1
output:
Alice
result:
wrong answer 1st words differ - expected: 'Bob', found: 'Alice'
Subtask #3:
score: 0
Wrong Answer
Test #55:
score: 15
Accepted
time: 0ms
memory: 12716kb
input:
7 0 0 1 1 0 1 1 1 2 2 3 4 0 2 5 6 0 1 7 0 1 1
output:
Bob
result:
ok "Bob"
Test #56:
score: -15
Wrong Answer
time: 3ms
memory: 13396kb
input:
6 0 1 0 0 1 0 2 2 6 3 3 4 5 0 0 0 0 1 1
output:
Alice
result:
wrong answer 1st words differ - expected: 'Bob', found: 'Alice'
Subtask #4:
score: 0
Wrong Answer
Test #103:
score: 20
Accepted
time: 2ms
memory: 12004kb
input:
10 1 1 1 1 1 1 1 1 1 1 1 2 4 3 5 7 8 1 4 0 1 6 0 0 1 9 1 10 0 1 1
output:
Alice
result:
ok "Alice"
Test #104:
score: 0
Accepted
time: 2ms
memory: 12108kb
input:
10 1 1 1 1 1 1 1 1 1 1 4 2 3 4 10 0 0 1 5 1 6 2 7 8 0 1 9 0 0 1 1
output:
Alice
result:
ok "Alice"
Test #105:
score: -20
Wrong Answer
time: 0ms
memory: 12676kb
input:
10 1 1 1 1 1 1 1 1 1 1 2 2 7 1 3 2 4 6 1 5 0 0 0 1 9 0 0 10 8 10 10 8 10 8 10 10 1 8
output:
Bob
result:
wrong answer 1st words differ - expected: 'Alice', found: 'Bob'
Subtask #5:
score: 0
Skipped
Dependency #4:
0%
Subtask #6:
score: 0
Skipped
Dependency #1:
0%