QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#827842#9783. Duloc NetworkZawosWA 1ms3524kbC++201.5kb2024-12-23 10:34:592024-12-23 10:34:59

Judging History

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

  • [2024-12-23 10:34:59]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3524kb
  • [2024-12-23 10:34:59]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using ii = pair<int, int>;
using vii = vector<ii>;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define all(x) x.begin(), x.end()
#define pb(x) push_back(x)

int ask(string s) {
    cout << "? " << s << endl;
    int res; cin >> res;
    return res;
}

string OR(string &a, string &b) {
    int n = a.size();
    string res(n, '0');
    rep(i, 0, n) 
        res[i] = "01"[a[i] == '1' || b[i] == '1'];
    return res;
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n; cin >> n;
    string A(n, '0'), B(n, '1');
    A[0] = '1'; B[0] = '0';
    int fA = ask(A);
    if (fA == 0) {
        return cout << "! 0" << endl, 0;
    }

    rep(i, 0, n - 1) {
        int l = 0, r = n - 1;
        // 1 - 2 - 3 - 4 - 5
        while (l <= r) {
            int m = (l + r) / 2;
            string query(n, '0');
            int cnt = 0;
            rep(j, l, m + 1) {
                query[j] = B[j];
                if (B[j] == '1')    
                    cnt++;
            }

            int fB = ask(query), fAB = fA + ask(OR(A, query));

            if (!fB) return cout << "! 0" << endl, 0;

            if (!cnt || fA + fB == fAB)
                l = m + 1;
            else
                r = m - 1;
        }

        if (l == n) return cout << "! 0" << endl, 0;

        A[l] = '1';
        B[l] = '0';
        fA = ask(A); 
    }

    cout << "! 1" << endl;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3524kb

input:

4
1
3
2
0
1

output:

? 1000
? 0100
? 1100
? 0000
? 1000
! 0

result:

wrong answer Wrong answer.