제출 #1357249

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

int query(int n, const vector<string>& s) {
    cout << "?\n";
    for(int i = 0; i < n; i++) cout << s[i] << endl;
    int x;
    if (!(cin >> x)) exit(0);
    return x;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    if (!(cin >> n)) return 0;

    vector<string> s(n, string(n, '0'));
    vector<int> h_pos(n);

    for(int i = 0; i < n; i++) {
        int low = 0, high = n - 1;
        int res_h = 0;

        while(low <= high) {
            int mid = low + (high - low) / 2;
            for(int j = 0; j < n; j++) s[i][j] = (j <= mid ? '1' : '0');
            
            int res = query(n, s);
            if (res < (mid + 1) * n) {
                res_h = mid;
                high = mid - 1;
            } else {
                low = mid + 1;
            }
        }
        h_pos[i] = res_h;
        for(int j = 0; j < n; j++) s[i][j] = '0';
    }

    cout << "!\n";
    for(int i = 0; i < n; i++) {
        string row(n, '0');
        row[h_pos[i]] = '1';
        cout << row << endl;
    }

    return 0;
}
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…