Submission #1369055

#TimeUsernameProblemLanguageResultExecution timeMemory
1369055AzeTurk810Light Bulbs (EGOI24_lightbulbs)C++20
0 / 100
0 ms344 KiB
/*
Telebe of Adicto && Mamedov yani AzeTurk810
I see humans but no humanity
*/
#include <cassert>
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>

// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

using ll = long long;
using namespace std;

#define ln '\n'
#define INFi 1e9
#define INFll 1e18

#ifdef ONPC
#include <algo.hpp>
#else
#define dbg(...)
#define dbg_out(...)
#define myassert(Expr, Msg) ;
#endif

size_t n;
vector<string> S, ans;

int ask() {
    cout << "?\n";
    for (size_t i = 0; i < n; i++) {
        cout << S[i] << '\n';
    }
    cout.flush();
    int res;
    cin >> res;
    return res;
}

void answer() {
    cout << "!" << endl;
    cout.flush();
    for (size_t i = 0; i < n; i++) {
        cout << ans[i] << ln;
    }
    cout.flush();
    exit(0);
}

inline void systemd() {
    S.resize(n, string(n, '0'));
    ans.resize(n, string(n, '0'));
}

char solve() {
    if (!(cin >> n))
        return 1;
    systemd();
    char full = false;
    { // NOTE: for rows
        S[0][0] = '1';
        int ind = -1;
        for (size_t j = 1; j < n; j++) {
            S[0][j] = '1';
            int res = ask();
            if (res == n) {
                S[0][j] = '0';
                break;
            } else if (res != n * 2) {
                ind = j;
            }
            if (j + 1 == n) {
                S[0][0] = '0';
                if (ind == -1) {
                    goto coloums;
                }
                S[0][ind] = '1';
            }
            S[0][j] = '0';
        }
        for (size_t i = 1; i < n; i++) {
            char flag = false;
            for (size_t j = 0; j < n; j++) {
                S[i][j] = '1';
                int res = ask();
                if (res == (i + 1) * n) {
                    dbg(i);
                    flag = true;
                    break;
                }
                S[i][j] = '0';
            }
            if (!flag) {
                break;
            }
            if (i + 1 == n) {
                ans = S;
                answer();
            }
        }
    }
coloums: { // NOTE: for coloums
    dbg("______");
    S.assign(n, string(n, '0'));
    S[0][0] = '1';
    for (size_t j = 1; j < n; j++) {
        for (size_t i = 0; i < n; i++) {
            S[i][j] = '1';
            int res = ask();
            if (res == (j + 1) * n) {
                break;
            }
            if (j + 1 == n && i + 1 == n) {
                myassert(0, "WA: PANIC PANIC PANIC");
            }
            S[i][j] = '0';
        }
    }
    ans = S;
    answer();
}
    myassert(0, "WA: No answer founded");
    return 0;
}

// Attack on titan<3

signed main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    int t = 1e9;
    // cin >> t;
    for (int cases = 0; cases < t; cases++) {
        if (solve())
            break;
#ifdef ONPC
        cerr << "__________\n";
#endif
    }
}
// Just Imaginary
/*
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣀⣀⠀⠀⠀⢀⣴⣾⠀⠀⠀⡀⢀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⣿⣿⣿⣦⣾⣿⣿⣿⣿⣿⡆⠁⠀⢀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠹⣿⣿⣿⣿⣿⣿⣿⣿⡿⠁⠀⡠⠂⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⠠⠔⠚⣿⣿⣿⣿⣿⣦⡄⠀⠁⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⢀⠠⠐⢂⠉⡀⣀⣤⣄⢻⣿⣿⡟⢈⡹⣿⡀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⡀⠄⠂⠈⠀⣶⣤⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠘⣷⡀⠀⡀⠐⠂⠐⢄
⠀⠀⠀⠀⠀⠀⠀⣿⣿⠟⠿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣧⣀⣾⣷⠯⠀⠤⠤⠄⠈
⠀⠀⠀⠀⠀⠀⣼⣿⡟⠀⠀⣹⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣄⡀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⣰⣿⠋⠀⠀⢠⣾⣿⣿⣿⣿⣿⣭⠟⢻⣿⣿⣿⣿⡿⠁⠀⠀⠀⠀
⠀⠀⠀⣀⣶⡟⠁⠀⢾⣶⣿⠟⠉⠈⢻⣿⣿⣿⣦⣜⠀⠛⠛⠿⠁⠀⠀⠀⠀⠀
⠚⠻⠿⠿⡿⠁⠀⢠⣿⣿⠁⠀⣠⠖⠋⠉⠻⣿⣿⣿⣶⡀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⣰⣿⡿⠃⠠⠊⠁⠀⠀⠀⠀⠈⢿⣿⣿⠟⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⢀⣴⡿⠋⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠘⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⣠⣾⠏⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⢀⣴⠾⠟⠛⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
*/
#Result Execution timeMemoryGrader output
Fetching results...
#Result Execution timeMemoryGrader output
Fetching results...
#Result Execution timeMemoryGrader output
Fetching results...