QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#140790 | #5156. Going in Circles | Anwar_Gehad_Maghraby# | RE | 31ms | 3764kb | C++23 | 2.0kb | 2023-08-16 20:23:55 | 2023-08-16 20:23:56 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
vector<int> wrt, readd;
int get(){
int r1= rand() & 1;
int r2= rand() & 1;
int r3= rand() & 1;
return (r1 + r2 + r3) & 1;
}
int Flip(){
cout<<"? flip\n"; cout.flush();
int x; cin>>x;
return x;
}
int Right(){
cout<<"? right\n"; cout.flush();
int x; cin>>x;
return x;
}
int Left(){
cout<<"? left\n"; cout.flush();
int x; cin>>x;
return x;
}
void out(int n){
cout<<"! "<<n; cout.flush();
exit(0);
}
int main() {
cin.tie(0);cin.sync_with_stdio(0);
cout.tie(0);cout.sync_with_stdio(0);
int cur;
cin>>cur;
int qs = 500;
while(qs)
{
readd.push_back(cur);
int put= get();
if(put != cur){
assert(Flip() == put);
qs--;
}
wrt.push_back(put);
cur= Right();
qs--;
}
int p = 0;
for(int i = 3; i < readd.size(); i++){
int n = i;
if(readd.size() >= 2 * n){
bool valid = 1;
for(int j = 0, k = i; k < readd.size(); k++, j++){
if(readd[k] != wrt[j]){
valid= 0;
break;
}
}
if(valid)
{
out(n);
}
p= i + 1;
}else break;
}
int ops = 3 * 5000 + 10;
while(ops--)
{
readd.push_back(cur);
int put= get();
if(put != cur){
assert(Flip() == put);
qs--;
}
wrt.push_back(put);
cur= Right();
while(readd.size() >= 2 * p)
{
int n = p;
bool valid = 1;
for(int j = 0, k = p; k < readd.size(); k++, j++){
if(readd[k] != wrt[j]){
valid= 0;
break;
}
}
if(valid)
{
out(n);
}
p++;
}
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 31ms
memory: 3760kb
input:
0 1 0 1 0 1 0 0 1 0 1 0 1 1 1 0 1 0 0 0 1 0 1 1 1 1 0 1 0 1 0 1 0 0 1 1 0 1 0 0 1 1 0 0 1 0 0 1 0 0 1 0 1 0 0 0 0 1 1 1 0 0 1 0 0 1 1 0 0 1 0 1 1 0 0 0 1 0 1 1 0 0 1 1 1 0 1 0 1 0 1 0 1 0 1 0 0 1 1 0 1 1 0 1 1 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 1 1 0 1 0 1 0 1 0 0 1 0 0 1 0 0 1 0 1 0 0 1 1 0 1 0 0 1 1 ...
output:
? right ? right ? flip ? right ? right ? flip ? right ? right ? right ? right ? flip ? right ? right ? right ? flip ? right ? flip ? right ? right ? right ? right ? right ? right ? right ? right ? flip ? right ? flip ? right ? flip ? right ? flip ? right ? flip ? right ? right ? right ? flip ? right...
result:
ok Queries used; 15085.
Test #2:
score: 0
Accepted
time: 13ms
memory: 3764kb
input:
1 0 0 1 1 1 0 1 0 0 1 1 0 0 0 1 0 1 0 1 0 0 0 1 0 0 1 0 1 0 1 1 0 1 0 1 0 1 0 0 1 0 1 1 0 1 0 0 1 0 0 1 0 1 0 0 1 1 0 0 1 0 1 1 0 0 1 0 1 0 1 1 0 0 1 0 1 0 1 0 1 0 1 1 0 1 0 1 0 0 1 0 1 1 0 1 0 1 0 1 0 0 0 1 0 1 0 1 0 1 0 0 1 1 0 1 0 1 0 1 1 0 1 1 0 0 1 0 1 0 1 1 0 1 0 1 0 1 1 0 0 1 1 0 0 1 1 0 1 0 ...
output:
? flip ? right ? flip ? right ? right ? flip ? right ? flip ? right ? right ? right ? flip ? right ? right ? flip ? right ? flip ? right ? right ? flip ? right ? right ? right ? right ? right ? flip ? right ? flip ? right ? flip ? right ? flip ? right ? flip ? right ? flip ? right ? flip ? right ? f...
result:
ok Queries used; 14582.
Test #3:
score: 0
Accepted
time: 5ms
memory: 3596kb
input:
0 0 1 1 0 0 0 0 1 1 0 0 0 1 1 0 0 0 1 0 1 0 0 1 0 1 0 1 1 0 1 0 0 1 0 0 1 0 1 1 0 0 1 1 0 0 1 0 0 0 1 0 1 0 1 1 0 1 0 0 0 1 1 1 0 1 0 0 1 1 0 0 0 1 1 0 1 0 1 0 0 1 0 1 1 0 1 0 1 0 1 0 0 1 1 0 1 0 0 1 1 0 1 0 0 1 0 0 1 1 0 1 1 0 1 1 0 0 1 0 1 0 1 1 0 1 0 1 0 1 1 0 1 0 0 1 1 0 1 0 0 0 0 1 0 1 0 1 0 1 ...
output:
? right ? flip ? right ? right ? right ? right ? right ? flip ? right ? flip ? right ? right ? flip ? right ? right ? right ? right ? right ? flip ? right ? right ? right ? flip ? right ? flip ? right ? flip ? right ? flip ? right ? flip ? right ? right ? flip ? right ? flip ? right ? flip ? right ?...
result:
ok Queries used; 15043.
Test #4:
score: 0
Accepted
time: 11ms
memory: 3672kb
input:
0 0 1 1 0 1 0 0 0 1 1 0 1 0 0 1 1 1 0 1 0 1 0 0 1 0 1 0 1 1 0 1 0 0 1 0 1 1 1 0 1 0 0 1 0 0 0 1 0 1 0 1 0 0 1 1 1 0 1 0 1 0 1 1 1 0 1 0 1 0 0 1 1 0 0 0 1 0 1 1 0 1 0 0 0 1 1 0 1 0 1 1 0 0 1 0 0 1 0 1 0 0 0 1 1 0 1 0 1 1 0 0 1 0 1 1 0 0 1 1 0 0 1 0 1 0 1 0 1 0 1 0 1 0 1 1 0 0 1 0 0 1 1 0 1 0 0 0 1 0 ...
output:
? right ? flip ? right ? right ? right ? flip ? right ? right ? flip ? right ? flip ? right ? flip ? right ? flip ? right ? right ? flip ? right ? flip ? right ? flip ? right ? right ? right ? right ? right ? flip ? right ? right ? right ? flip ? right ? right ? flip ? right ? right ? right ? flip ?...
result:
ok Queries used; 12294.
Test #5:
score: 0
Accepted
time: 20ms
memory: 3516kb
input:
0 0 1 1 0 1 0 0 0 1 1 0 1 0 0 1 1 1 0 1 0 1 0 0 1 0 1 0 1 1 0 1 0 0 1 0 1 1 1 0 1 0 0 1 0 0 0 1 0 1 0 1 0 0 1 1 1 0 1 0 1 0 1 1 1 0 1 0 1 0 0 1 1 0 0 0 1 0 1 1 0 1 0 0 0 1 1 0 1 0 1 1 0 0 1 0 0 1 0 1 0 0 0 1 1 0 1 0 1 1 0 0 1 0 1 1 0 0 1 1 0 0 1 0 1 0 1 0 1 0 1 0 1 0 1 1 0 0 1 0 0 1 1 0 1 0 0 0 1 0 ...
output:
? right ? flip ? right ? right ? right ? flip ? right ? right ? flip ? right ? flip ? right ? flip ? right ? flip ? right ? right ? flip ? right ? flip ? right ? flip ? right ? right ? right ? right ? right ? flip ? right ? right ? right ? flip ? right ? right ? flip ? right ? right ? right ? flip ?...
result:
ok Queries used; 12244.
Test #6:
score: 0
Accepted
time: 25ms
memory: 3544kb
input:
0 0 1 1 0 1 0 0 0 1 1 0 1 0 0 1 1 1 0 1 0 1 0 0 1 0 1 0 1 1 0 1 0 0 1 0 1 1 1 0 1 0 0 1 0 0 0 1 0 1 0 1 0 0 1 1 1 0 1 0 1 0 1 1 1 0 1 0 1 0 0 1 1 0 0 0 1 0 1 1 0 1 0 0 0 1 1 0 1 0 1 1 0 0 1 0 0 1 0 1 0 0 0 1 1 0 1 0 1 1 0 0 1 0 1 1 0 0 1 1 0 0 1 0 1 0 1 0 1 0 1 0 1 0 1 1 0 0 1 0 0 1 1 0 1 0 0 0 1 0 ...
output:
? right ? flip ? right ? right ? right ? flip ? right ? right ? flip ? right ? flip ? right ? flip ? right ? flip ? right ? right ? flip ? right ? flip ? right ? flip ? right ? right ? right ? right ? right ? flip ? right ? right ? right ? flip ? right ? right ? flip ? right ? right ? right ? flip ?...
result:
ok Queries used; 12318.
Test #7:
score: -100
Dangerous Syscalls
input:
0 0 1 0 1 0 0 0 0 1 0 0 0 1 0 1 0 0 0 0 0 1 0 0 1 0 1 0 1 0 0 0 0 0 1 0 1 0 0 0 1 0 0 0 1 0 0 0 1 0 0 1 0 1 0 0 0 0 1 0 1 0 0 0 0 1 0 0 1 0 1 0 0 0 0 1 0 1 0 0 1 0 1 0 0 0 0 1 0 1 0 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 1 0 1 0 1 0 1 0 0 1 0 1 0 0 1 0 0 1 0 0 0 0 0 1 0 1 0 0 0 1 1 0 0 0 1 0 0 ...
output:
? right ? flip ? right ? flip ? right ? right ? right ? right ? flip ? right ? right ? right ? flip ? right ? flip ? right ? right ? right ? right ? right ? flip ? right ? right ? flip ? right ? flip ? right ? flip ? right ? right ? right ? right ? right ? flip ? right ? flip ? right ? right ? right...