QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#103006 | #5156. Going in Circles | w4p3r | TL | 0ms | 0kb | C++20 | 1.4kb | 2023-05-03 22:05:04 | 2023-05-03 22:05:14 |
Judging History
answer
#include<bits/stdc++.h>
#define inf 1e9
#define eps 1e - 6
#define FOR(i, a, b) for(int i = a;i <= b;i ++)
#define REP(i, a, b) for(int i = a;i >= b;i --)
#define pa pair<int, int>
#define fr first
#define sd second
#define pb push_back
#define db double
#define MEM(a) memset(a, 0, sizeof(a))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
inline ll read()
{
char ch = getchar();
ll s = 0, w = 1;
while (ch < '0' || ch > '9') {if (ch == '-')w = -1; ch = getchar();}
while (ch >= '0' && ch <= '9') {s = s * 10 + ch - '0'; ch = getchar();}
return s * w;
}
int n;
inline void qry(string a, int &x)
{
cout << "?" << a << endl;
cin >> x;
}
int main()
{
int t;
cin >> t;
FOR(len, 3, 20)
{
int cur = t;
int tmp = len;
while (tmp --) qry("right", t);
if (t != cur) continue; tmp = len;
qry ("flip", t);
while (tmp --) qry("left", t);
if (t == cur) continue;
cout << "!" << len << endl;
return 0;
}
mt19937 rnd(time(0));
int c[21];
FOR(i, 1, 20) c[i] = rnd() % 2;
FOR(i, 1, 20)
{
if(t != c[i]) qry("flip", t);
qry("right", t);
}
deque<int> now; now.push_back(t);int s = 1;
while(true)
{
qry("right", t); s++; now.push_back(t);
if(now.size() < 20) continue;
if(now.size() > 20) now.pop_front();
int fl = 0;
FOR(i, 1, 20)if (c[i] != now[i-1]) fl = 1;
if (!fl) {cout<< "! " << n <<endl; return 0;}
}
return 0;
}
详细
Test #1:
score: 0
Time Limit Exceeded
input:
0
output:
?right