QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#96381#5156. Going in CirclesSa3tElSefr#WA 4ms3428kbC++142.8kb2023-04-13 20:48:032023-04-13 20:48:06

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-04-13 20:48:06]
  • 评测
  • 测评结果:WA
  • 用时:4ms
  • 内存:3428kb
  • [2023-04-13 20:48:03]
  • 提交

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;
    vals.push_back(cur);
    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;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 4ms
memory: 3428kb

input:

0
1
0
1
0
1
0
1
1
0
0
1
1
0
1
0
1
1
1
0
1
0
1
0
0
1
1
0
1
1
1
1
1
0
1
0
0
1
0
1
0
1
1
0
1
1
0
0
1
1
0
0
0
0
1
0
0
0
1
1
1
0
0
1
0
1
0
1
1
0
1
0
0
0
1
0
0
1
1
0
0
1
1
0
1
1
0
1
0
1
0
0
0
1
1
0
0
1
1
0
1
0
1
1
0
1
1
0
0
1
0
1
1
0
0
1
1
0
0
1
0
0
1
0
0
0
1
0
0
1
0
0
1
0
1
1
0
1
0
0
1
0
1
0
0
1
0
0
0
0
...

output:

? right
? right
? flip
? right
? right
? right
? flip
? right
? flip
? right
? flip
? right
? flip
? right
? flip
? right
? right
? right
? right
? flip
? right
? right
? flip
? right
? flip
? right
? flip
? right
? right
? right
? right
? right
? flip
? right
? flip
? right
? right
? right
? right
...

result:

wrong answer Wrong answer: incorrect guess 1 (ans: 5000). Queries used: 394