QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#66557#5156. Going in Circleskaruna#WA 6ms3376kbC++171.2kb2022-12-08 21:43:482022-12-08 21:43:49

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-12-08 21:43:49]
  • 评测
  • 测评结果:WA
  • 用时:6ms
  • 内存:3376kb
  • [2022-12-08 21:43:48]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

mt19937 rnd(15'571'557);
int rd(int r) {
    return uniform_int_distribution<int>(0, 1)(rnd);
}
int ans[5050];
vector<int> A, B;

int func(vector<int> S, vector<int> T) {
    for (int x : T) S.push_back(x);
    int n = S.size();
    vector<int> f(n);
    for (int i = 1; i < n; i++) {
        int j = f[i - 1];
        while (j && S[j] != S[i]) j = f[j - 1];
        if (S[j] == S[i]) f[i] = j + 1;
    }
    return n / 2 - f[n - 1];
}
int main() {
    int s; cin >> s; 
    int cnt = 0, sz = 0;
    while (!sz || cnt < 50) {
        int f = rd(0);
        if (f) {
            A.push_back(s);
            B.push_back(s);
        }
        else {
            A.push_back(s);
            B.push_back(!s);
            cout << "? flip" << endl;
            cin >> s;
            ++cnt;
        }
        if (A.size() >= 6 && A.size() % 2 == 0) {
            int x = func(B, A);
            ans[x]++;
            ++sz;
        }
        cout << "? right" << endl;
        cin >> s;
        ++cnt;
    }
    int res = max_element(ans + 3, ans + 5050) - ans;
    cout << "! " <<  res << endl;
    
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 6ms
memory: 3376kb

input:

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

output:

? flip
? right
? flip
? right
? right
? right
? flip
? right
? flip
? right
? flip
? right
? flip
? right
? flip
? right
? right
? flip
? right
? right
? right
? right
? flip
? right
? flip
? right
? flip
? right
? right
? right
? flip
? right
? right
? flip
? right
? flip
? right
? flip
? right
? r...

result:

wrong answer Wrong answer: incorrect guess 31 (ans: 5000). Queries used: 50