QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#103006#5156. Going in Circlesw4p3rTL 0ms0kbC++201.4kb2023-05-03 22:05:042023-05-03 22:05:14

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-05-03 22:05:14]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:0kb
  • [2023-05-03 22:05:04]
  • 提交

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;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Time Limit Exceeded

input:

0

output:

?right

result: