QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#66131 | #5156. Going in Circles | feeder1# | TL | 0ms | 0kb | C++14 | 1.1kb | 2022-12-07 00:22:44 | 2022-12-07 00:22:46 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
int t, cur;
cin >> t;
for (int i=3; i<=20; i+=2) {
cur = t;
for (int j=1; j<=i; j++) {
cout << "? right" << endl;
cin >> t;
}
if (t != cur) continue;
cout << "? flip" << endl;
cin >> t;
for (int j=1; j<=i; j++) {
cout << "? left" << endl;
cin >> t;
}
if (t == cur) continue;
cout << "! " << i << endl;
return 0;
}
srand(123);
int cmp[20];
for (int i=0; i<20; i++) cmp[i] = rand() % 2;
if (cmp[0] != t) {
cout << "? flip" << endl;
cin >> t;
}
for (int i=1; i<20; i++) {
cout << "? right" << endl;
cin >> t;
if (t == cmp[i]) continue;
cout << "? flip" << endl;
cin >> t;
}
deque<int> dq;
int n = 0;
while (true) {
cout << "? right" << endl;
cin >> t;
dq.push_back(t);
n++;
if (dq.size() > 20) dq.pop_back();
if (dq.size() < 20) continue;
bool same = 1;
for (int i=0; i<20; i++) {
if (cmp[i] != dq[i]) {
same = 0;
break;
}
}
if (!same) continue;
cout << "! " << n << endl;
return 0;
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Time Limit Exceeded
input:
0 1 0 0 1 0 1 0 1 0 1 1 0 1 1 1 0 1 0 1 0 1 1 1 1 0 1 1 1 1 1 0 1 0 1 0 1 1 1 1 1 1 1 1 1 1 0 0 1 0 1 1 1 1 0 1 1 1 0 1 0 0 1 1 1 1 1 1 1 0 0 1 0 1 1 1 0 1 1 0 1 0 1 1 1 0 1 0 0 1 1 1 1 1 1 1 0 0 1 0 1 1 1 0 1 0 1 0 1 0 1 0 1 0 1 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 ...
output:
? right ? right ? right ? flip ? left ? left ? left ? right ? right ? right ? right ? right ? flip ? left ? left ? left ? left ? left ? right ? right ? right ? right ? right ? right ? right ? flip ? left ? left ? left ? left ? left ? left ? left ? right ? right ? right ? right ? right ? right ? righ...