QOJ.ac
QOJ
The 2nd Universal Cup Finals is coming! Check out our event page, schedule, and competition rules!
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#120440 | #5158. Interview Question | PetroTarnavskyi# | TL | 0ms | 0kb | C++17 | 1.8kb | 2023-07-06 18:16:39 | 2023-07-06 18:16:43 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
using VI = vector<int>;
using VL = vector<LL>;
using PII = pair<int, int>;
using PLL = pair<LL, LL>;
using ld = long double;
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define F first
#define S second
#define FOR(i, a, b) for (int i = (a); i<(b); ++i)
#define RFOR(i, b, a) for (int i = (b)-1; i>=(a); --i)
#define FILL(a, b) memset(a, b, sizeof(a))
int hs = 447477;
int val = hs;
const int len = 20;
void check(int x)
{
int a = 0;
FOR (i, 0, x)
{
cout << "? left" << endl;
cin >> a;
}
if (a == 0)
{
cout << "! " << x << endl;
exit(0);
}
FOR (i, 0, x)
{
cout << "? right" << endl;
cin >> a;
}
}
void build()
{
int x;
cin >> x;
if (x == 0) cout << "? flip" << endl;
cout << "? right" << endl;
FOR (i, 1, len)
{
cin >> x;
if (x == 1)
{
cout << "? flip" << endl;
cin >> x;
check(i);
}
if ((hs >> i) & 1)
{
cout << "? flip" << endl;
cin >> x;
}
cout << "? right" << endl;
}
}
VI v;
bool bad()
{
if (SZ(v) == 1) return true;
if (SZ(v) % 2 == 0) return true;
int l = v.back() - v[0];
if (l & 1) return true;
l /= 2;
FOR (i, 0, SZ(v) / 2)
{
if (v[i] + l != v[i + SZ(v) / 2]) return true;
}
cout << "! " << l << endl;
exit(0);
return false;
}
void solve()
{
build();
v.PB(len - 1);
int idx = len;
int x;
while (bad())
{
cin >> x;
val >>= 1;
val += x << (len - 1);
if (val == hs)
v.PB(idx);
idx++;
cout << "? right" << endl;
}
}
int main()
{
//ios_base::sync_with_stdio(0);
//cin.tie(0);
int t = 1;
//cin >> t;
while (t--)
{
solve();
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Time Limit Exceeded
input:
7 11 7 8 Fizz Buzz 11
output:
? right ? right ? flip ? right ? right ? flip ? right ? flip ? right ? flip ? right ? flip ? right ? flip ? right ? flip ? right ? right ? right ? flip ? right ? right ? flip ? right ? flip ? right ? right ? flip ? right ? flip ? right ? right ? right ? right ? right ? right ? right ? right ? right ...