QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#66557 | #5156. Going in Circles | karuna# | WA | 6ms | 3376kb | C++17 | 1.2kb | 2022-12-08 21:43:48 | 2022-12-08 21:43:49 |
Judging History
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