QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#96382 | #5156. Going in Circles | Sa3tElSefr# | TL | 0ms | 0kb | C++14 | 2.7kb | 2023-04-13 20:49:24 | 2023-04-13 20:49:28 |
Judging History
answer
///Etfsh5t nseet el rank
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx,avx2,fma")
#include "bits/stdc++.h"
using namespace std;
#define pb push_back
#define F first
#define S second
#define f(i, a, b) for (int i = a; i < b; i++)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define sz(x) (int)(x).size()
#define mp(x, y) make_pair(x, y)
#define popCnt(x) (__builtin_popcountll(x))
// #define int ll
using ll = long long;
using ull = unsigned long long;
using uint = uint32_t;
using ii = pair<int, int>;
const int N = 2e5 + 5, A = 12, LG = 18, MOD = (119 << 23) + 1;
const long double PI = acos(-1);
const long double EPS = 1e-9;
const int INF = 1e18;
string str = "101010101001";
int ptr = 0;
bool ask(string x)
{
// if (x == "left")
// {
// ptr = (ptr + str.size() - 1) % str.size();
// return str[ptr] - '0';
// }
// if (x == "right")
// {
// ptr = (ptr + 1) % str.size();
// return str[ptr] - '0';
// }
// if (x == "flip")
// {
// str[ptr] ^= 1;
// return str[ptr] - '0';
// }
cout << "? " << x << endl;
bool ret;
cin >> ret;
return ret;
}
const int MX = 100;
void doWork()
{
// cout << str.size() << endl;
srand(time(0));
int cur;
cin >> cur;
vector<int> vals;
for (int i = 0; i < MX; i++)
{
vals.push_back(cur);
int val = rand() & 1;
if (ask("right") != val)
ask("flip");
cur = val;
}
bool small = false;
for (int i = 0; i < MX; i++)
{
int val = ask("left");
if (val != vals[MX - 1 - i])
{
small = true;
}
}
if (small)
{
for (int i = 0; i < MX; i++)
{
if (cur)
ask("flip");
cur = ask("right");
}
ask("flip");
for (int i = 1;; i++)
{
if (ask("right"))
{
cout << "! " << i << endl;
return;
}
}
}
deque<int> vec;
for (int i = 0; i < MX; i++)
{
vec.push_back(cur);
cur = ask("right");
}
deque<int> dq;
for (int i = 1;; i++)
{
dq.push_back(cur);
cur = ask("right");
if (dq.size() > MX)
dq.pop_front();
if (dq == vec)
{
cout << "! " << i << endl;
return;
}
}
}
int32_t main()
{
#ifdef ONLINE_JUDGE
ios_base::sync_with_stdio(0);
cin.tie(0);
#endif // ONLINE_JUDGE
int t = 1;
// cin >> t;
while (t--)
{
doWork();
}
return 0;
}
詳細信息
Test #1:
score: 0
Time Limit Exceeded
input:
0 1 0 0 1 0 1 1 0 1 1 1 0 1 0 1 1 0 0 0 1 1 0 0 1 0 1 0 1 1 0 1 1 0 1 0 1 1 0 1 0 1 0 1 0 0 1 0 1 0 1 0 1 0 0 1 0 1 0 1 1 0 1 0 0 1 1 0 1 0 1 1 0 0 1 0 0 1 0 1 1 0 1 0 0 1 1 0 1 0 1 0 1 0 1 0 0 0 1 1 0 1 0 1 0 1 0 1 1 0 1 1 0 0 1 0 0 1 1 0 0 1 1 0 1 0 0 1 0 1 1 0 0 0 1 0 0 0 0 1 0 1 0 0 1 1 0 1 1 0 ...
output:
? right ? right ? right ? right ? right ? flip ? right ? right ? flip ? right ? right ? flip ? right ? flip ? right ? right ? flip ? right ? right ? flip ? right ? flip ? right ? right ? flip ? right ? flip ? right ? right ? flip ? right ? right ? flip ? right ? right ? flip ? right ? right ? right ...