QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#133869#5156. Going in CirclesBUET_TEAM_ONE#TL 0ms0kbC++202.2kb2023-08-02 16:03:062023-08-02 16:03:08

Judging History

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

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

answer

#include <bits/stdc++.h>
typedef long long int ll;
#define pb             push_back
#define mp              make_pair
#define pll             pair<ll,ll> 
#define fill(x, y)     memset(x, y, sizeof(x))
#define all(x)         (x).begin(), (x).end()
#define debug(x)       { cerr << #x << " = " << x << endl; }
#define IO	       { ios_base::sync_with_stdio(false); cin.tie(0); }
#define read(x)	       freopen(x, "r", stdin)
#define write(x)       freopen(x, "w", stdout)


using namespace std;

mt19937 mt(time(nullptr)); 


void left() {
    cout << "? left" << endl;
}
void right() {
    cout << "? right" << endl;
}
void flip() {
    cout << "? flip" << endl;
}

const int N = 64;
bitset<N> org;
bitset<N> cur_seq;


void solve() {
    int cur;
    

    
    bool flag = true;
    
    for (int i=0; i<N; i++) {
        cin >> cur;
        if (cur != 0) {
            flip();
            cin >> cur;
        }
        right();
    }
    for (int i=0; i<N; i++) {
        cin >> cur;
        if (cur != 1) {
            flip();
            cin >> cur;
        }
        right();
    }
    cin >> cur;
    bool allOne = true;
    for (int i=0; i<2*N; i++) {
        left();
        cin >> cur;
        if (cur != 1) allOne = false;
    }


    if (allOne) {
        // length <= N
        flip();
        cin >> cur;
        int i = 1;
        while(1) {
            right();
            cin >> cur;
            if (cur == 0) break;
            i++;
        }
        cout <<"! "<< i<< endl;
    } else {
        // length > N
        for(int i=0;i<N;i++){
            org[i]=mt()%2;
        }

        for(int i=0; i<N; i++) {
            right();
            cin >> cur;
            if (cur != org[i]) {
                flip();
                cin >> cur;
            }
        }

        cur_seq = org;
        int idx = 1;

        while(1) {
            right();
            cin >> cur;

            cur_seq <<= 1;
            cur_seq |= cur;

            if ( (cur_seq ^ org).count() == 0 ) break;
            idx++;
        } 
        cout <<"! "<< idx << endl;


    }
}

int main() {
    
    cout << fixed << setprecision(10);
    solve();
}

詳細信息

Test #1:

score: 0
Time Limit Exceeded

input:

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

output:

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

result: