QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#421221 | #5018. nth | marher | 0 | 30ms | 18648kb | C++14 | 3.6kb | 2024-05-25 15:35:20 | 2024-05-25 15:35:20 |
Judging History
answer
#include "nth.h"
#include<bits/stdc++.h>
using namespace std;
namespace Alice
{
int cnt,m,n,a[5000000],pos=20,L=0,R=(1<<21)-1,ty;
void sol()
{
if(n<=2)
{
for(int i=1;i<=n;i++)for(int j=20;j>=0;j--)sendA((a[i]>>j)&1);
return;
}
int p=(n+1)/2;
sendA((a[p]>>pos)&1);
}
void initA(std::bitset<M> A, unsigned S,unsigned c)
{
for(int i=0;i<M;i++)if(A[i])a[++n]=i;
m=S-n;
if(c<=min(n,m))n=c,ty=0;
else if(c<=max(n,m))
{
if(n>m)
{
for(int i=c-m;i<=c;i++)a[i-(c-m)+1]=a[i];
n=m+1;
}
else
{
n++;
for(int i=n;i;i--)a[i]=a[i-1];
}
c=n+1;ty=1;
}
else
{
for(int i=c-m;i<=n;i++)a[i-(c-m)+1]=a[i];
n=n-c+m+1;c=n+1;ty=1;
}
sol();
// cerr<<"find A "<<ty<<'\n';
// for(int i=1;i<=n;i++)cerr<<a[i]<<' ';puts("");
}
void receiveA(bool w)
{
int p=(n+1)/2,x=(a[p]>>pos)&1;w^=x;
if(w>x)
{
for(int i=p;i<=n;i++)a[i-p+1]=a[i];
n-=p-1;
}
if(w<x)n=p;
if(w==x)
{
int val=(a[p]>>pos)<<pos;
int l=val,r=val+(1<<pos)-1;
// cerr<<"exexexexA "<<l<<' '<<r<<' '<<val<<' '<<pos<<'\n';
for(int i=1;i<=n;i++)a[i]=min(r,a[i]),a[i]=max(l,a[i]);
}
// cerr<<"A "<<n<<' '<<p<<' '<<pos<<' '<<x<<' '<<w<<'\n';
// for(int i=1;i<=n;i++)cerr<<a[i]<<' ';cerr<<'\n';
pos-=!(w^x);sol();
}
}
namespace Bob
{
int m,n,a[5000000],pos=20,L=0,R=(1<<21)-1,ty;
void initB(std::bitset<M> A, unsigned S,unsigned c)
{
for(int i=0;i<M;i++)if(A[i])a[++n]=i;
m=S-n;
if(c<=min(n,m))n=c,ty=0;
else if(c<=max(n,m))
{
if(n>m)
{
for(int i=c-m;i<=c;i++)a[i-(c-m)+1]=a[i];
n=m+1;
}
else
{
n++;
for(int i=n;i;i--)a[i]=a[i-1];
}
c=n+1;ty=1;
}
else
{
for(int i=c-m;i<=n;i++)a[i-(c-m)+1]=a[i];
n=n-c+m+1;c=n+1;ty=1;
}
// cerr<<"find B "<<ty<<'\n';
// for(int i=1;i<=n;i++)cerr<<a[i]<<' ';puts("");
}
int cnt=0,re[50]={0,0,0},hv=1;
void receiveB(bool x)
{
if(n<=2)
{
// cerr<<x<<' ';
int z=x;
re[hv]<<=1,re[hv]|=x;cnt++;
if(cnt==21)
{
cnt=0;++hv;
// puts("");
if(hv>n)
{
for(int i=1;i<=n;i++)re[hv++]=a[i];
std::sort(re+1,re+hv);
report(ty?re[n+1]:re[n]);
}
}
return;
}
int p=n/2+1,w=(a[p]>>pos)&1;
if(w<x)
{
for(int i=p;i<=n;i++)a[i-p+1]=a[i];
n-=p-1;
}
if(w>x)n=p;
if(w==x)
{
if(!pos)report(a[1]);
int val=(a[p]>>pos)<<pos;
int l=val,r=val+(1<<pos)-1;
for(int i=1;i<=n;i++)a[i]=min(r,a[i]),a[i]=max(l,a[i]);
}
pos-=!(w^x);sendB(w^x);
// cerr<<"B "<<n<<' '<<p<<' '<<pos<<' '<<x<<' '<<w<<'\n';
// for(int i=1;i<=n;i++)cerr<<a[i]<<' ';cerr<<'\n';
}
}
详细
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 100
Accepted
time: 29ms
memory: 16492kb
input:
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
output:
3196614622 1083345 21
result:
points 1.0 OK L = 21
Test #2:
score: 100
Accepted
time: 30ms
memory: 16680kb
input:
111111100101001001100100000000111110101000101001001100101010011110000110101011010000000001000111000001011011110101010111001101010000101001101011101001110011001001101111110100001111001001010000110000011011000101010010000000011010010111110000111011011100110000100101111000111111110001100110110111101001...
output:
4153393124 307591 21
result:
points 1.0 OK L = 21
Test #3:
score: 100
Accepted
time: 28ms
memory: 18648kb
input:
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
output:
1444424234 522975 42
result:
points 1.0 OK L = 42
Test #4:
score: 100
Accepted
time: 28ms
memory: 17956kb
input:
001101001011011011110001100111001010010100110110111111100011101010001111110101110101110011111001110110111010001100100011010101011000000000001010010001011111110101111100000101000010101110100000110101010100100100010010110010010000001010010100110110100101111110010011011111011111110010100010001110110011...
output:
3619264599 491607 42
result:
points 1.0 OK L = 42
Test #5:
score: 0
Wrong Answer
time: 13ms
memory: 14476kb
input:
111111100110100111101001011010001100010101010010010110010010101011100111110111101101011110111100011001100010111011001000101000111000000000001010110001111010001110110100111110101011000001110000010100111010001110110111000001010101010001110110100111110011111001001101000011101010111010111001100010010000...
output:
2453620143 222310 69
result:
wrong answer Wrong Answer.