제출 #1241059

#제출 시각아이디문제언어결과실행 시간메모리
1241059woeLight Bulbs (EGOI24_lightbulbs)C++20
0 / 100
0 ms412 KiB
#include <iostream>
using namespace std;

int N;
string grid[100];

int ask() {
    cout << "?" << endl;
    for (int i = 0; i < N; ++i)
        cout << grid[i] << endl;
    cout.flush();
    int lit;
    cin >> lit;
    return lit;
}

int main() {
    cin >> N;

    for (int i = 0; i < N; ++i)
        grid[0] += '1';
    for (int i = 1; i < N; ++i)
        grid[i] = string(N, '0');
    int rowLit = ask();

    for (int i = 0; i < N; ++i)
        grid[i] = string(N, '0');
    for (int i = 0; i < N; ++i)
        grid[i][0] = '1';
    int colLit = ask();

    bool isRowLamp[N];
    if (rowLit >= colLit) {
        isRowLamp[0] = true;
        for (int i = 1; i < N; ++i) {
            for (int j = 0; j < N; ++j)
                grid[j] = string(N, '0');
            for (int j = 0; j < N; ++j)
                grid[i][j] = '1';
            int lit = ask();
            isRowLamp[i] = (lit == N);
        }
    } else {
        isRowLamp[0] = false;
        for (int i = 1; i < N; ++i) {
            for (int j = 0; j < N; ++j)
                grid[j] = string(N, '0');
            for (int j = 0; j < N; ++j)
                grid[j][i] = '1';
            int lit = ask();
            isRowLamp[i] = (lit == N);
        }
    }

    cout << "!" << endl;
    for (int i = 0; i < N; ++i) {
        if (isRowLamp[i]) grid[i] = string(N, '1');
        else {
            grid[i] = string(N, '0');
            for (int j = 0; j < N; ++j)
                if (!isRowLamp[j])
                    grid[j][i] = '1';
        }
        cout << grid[i] << endl;
    }
    cout.flush();
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...