Submission #1364587

#TimeUsernameProblemLanguageResultExecution timeMemory
1364587biserailievaLight Bulbs (EGOI24_lightbulbs)C++20
0 / 100
0 ms352 KiB
#include <bits/stdc++.h>
using namespace std;

int n;

int askRow(int row, int l, int r) {
    cout << "?" << endl;

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (i == row && j >= l && j <= r) cout << 1;
            else cout << 0;
        }
        cout << endl;
    }

    int ans;
    cin >> ans;
    return ans;
}

int askFullRow(int row) {
    cout << "?" << endl;

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            cout << (i == row ? 1 : 0);
        }
        cout << endl;
    }

    int ans;
    cin >> ans;
    return ans;
}

int findV(int row) {
    int base = askFullRow(row);

    int l = 0, r = n - 1;
    int pos = -1;

    while (l <= r) {
        int mid = (l + r) / 2;

        int val = askRow(row, 0, mid);

        if (val > base) {
            pos = mid;
            r = mid - 1;
        } else {
            l = mid + 1;
        }
    }

    return pos;
}

int main() {
    cin >> n;

    int vcol = findV(0);

    vector<vector<int>> ans(n, vector<int>(n, 0));

    if (vcol != -1) {
        for (int i = 0; i < n; i++) ans[i][vcol] = 1;
    } else {
        for (int j = 0; j < n; j++) ans[0][j] = 1;
    }

    cout << "!" << endl;
    for (auto &row : ans) {
        for (int x : row) cout << x;
        cout << endl;
    }

    return 0;
}
#Result Execution timeMemoryGrader output
Fetching results...
#Result Execution timeMemoryGrader output
Fetching results...
#Result Execution timeMemoryGrader output
Fetching results...