제출 #1324551

#제출 시각아이디문제언어결과실행 시간메모리
1324551haithamcoderLight Bulbs (EGOI24_lightbulbs)C++20
0 / 100
0 ms332 KiB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;

const ll LOG = 31;
const ll MOD = 1000000007;
const ll inf = 1e17;
const ll B = 2305843009213693951;


#define db(x) cerr << #x << " = " << x << " | "
#define dbg(x) cerr << #x << " = " << x << "\n"

#define Algerian ios::sync_with_stdio(0);
#define OI cin.tie(NULL);

ll n;

bool query(ll x, ll y) {
    vector<string> a(n, string(n, '0'));
    a[0][0] = '1';
    a[x][y] = '1';
    cout << "?" << endl;
    for (ll i = 0; i < n; i++) {
        cout << a[i] << "\n";
    }
    cout << endl;
    ll res;
    cin >> res;
    return res == 2 * n;
}

int main() {
    Algerian OI

    cin >> n;

    vector<vector<bool>> dir(n, vector<bool>(n));
    dir[0][0] = 1;
    for (ll i = 0; i < n; i++) {
        for (ll j = 0; j < n; j++) {
            if (i == 0 && j == j) continue;
            dir[i][j] = query(i, j);
        }
    }

    vector<ll> good(n, -1);
    for (ll i = 0; i < n; i++) {
        for (ll j = 0; j < n; j++) {
            if (dir[i][j]) good[i] = j;
        }
    }

    ll bad = -1;
    for (ll i = 0; i < n; i++) {
        if (good[i] == -1) bad = i;
    }

    vector<string> a(n, string(n, '0'));
    if (bad == -1) {
        for (ll i = 0; i < n; i++) {
            a[i][good[i]] = '1';
        }
    } else {
        for (ll i = 0; i < n; i++) {
            a[bad][i] = '1';
        }
    }

    cout << "!" << endl;
    for (ll i = 0; i < n; i++) {
        cout << a[i] << "\n";
    }
    cout << endl;

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