QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#140789#5156. Going in CirclesAnwar_Gehad_Maghraby#WA 26ms3596kbC++232.0kb2023-08-16 20:22:582023-08-16 20:23:01

Judging History

你现在查看的是最新测评结果

  • [2023-08-16 20:23:01]
  • 评测
  • 测评结果:WA
  • 用时:26ms
  • 内存:3596kb
  • [2023-08-16 20:22:58]
  • 提交

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 = 10;
    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: 26ms
memory: 3596kb

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: -100
Wrong Answer
time: 1ms
memory: 3584kb

input:

1
0
0
1
1
1
0
1
0
0
1
1
0
0
0
1
0

output:

? flip
? right
? flip
? right
? right
? flip
? right
? flip
? right
? right
? right
? flip
? right
? right
? flip
? right
! 5

result:

wrong answer Wrong answer: incorrect guess 5 (ans: 4851). Queries used: 16