QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#226616 | #5018. nth | Adam_GS | 0 | 120ms | 10688kb | C++20 | 1.4kb | 2023-10-26 10:48:48 | 2023-10-26 10:48:49 |
Judging History
answer
#include "nth.h"
#include<bits/stdc++.h>
using namespace std;
namespace Alice {
bitset<M>A;
int po, ko, sr, k, l, r;
bool check(int x) {
int sum=0;
for(int i=l; i<=x && i<=r; ++i) if(A[i]) ++sum;
if(k==1) return sum>=1;
return sum>=k/2;
}
void initA(std::bitset<M> _A,unsigned S,unsigned c) {
A=_A;
k=c;
po=l=0;
ko=r=M-1;
sr=(po+ko)/2;
sendA(check(sr));
}
void receiveA(bool x) {
bool y=check(sr);
if(!x && !y) po=sr+1;
else if(x && y) ko=sr;
else if(y) {
int sum=k/2;
while(l<=r && sum) {
if(A[l]) --sum;
++l;
}
k-=k/2;
} else k-=(k+1)/2;
if(po==ko) {
report(po);
return;
}
sr=(po+ko)/2;
sendA(check(sr));
}
}
namespace Bob {
bitset<M>B;
int po, ko, sr, k, l, r;
bool check(int x) {
int sum=0;
for(int i=l; i<=x && i<=r; ++i) if(B[i]) ++sum;
return sum>=(k+1)/2;
}
void initB(std::bitset<M> _B,unsigned S,unsigned c) {
B=_B;
k=c;
po=l=0;
ko=r=M-1;
sr=(po+ko)/2;
}
void receiveB(bool x) {
bool y=check(sr);
sendB(y);
if(!x && !y) po=sr+1;
else if(x && y) ko=sr;
else if(y) {
int sum=(k+1)/2;
while(l<=r && sum) {
if(B[l]) --sum;
++l;
}
k-=(k+1)/2;
} else k-=k/2;
if(po==ko) {
report(po);
return;
}
sr=(po+ko)/2;
}
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 120ms
memory: 10688kb
input:
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
output:
3196614622 1048576 82
result:
wrong answer Wrong Answer.