답안 #1053716

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1053716 2024-08-11T16:11:51 Z Ludissey Light Bulbs (EGOI24_lightbulbs) C++17
0 / 100
0 ms 344 KB
#include <bits/stdc++.h>
#define int long long
#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()
 
using namespace std;
int N,M,Q;
vector<vector<int>> grid;
 
void output(){
    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < N; j++)
        {
            cout << grid[i][j] << " ";
        }
        cout << endl;
    }
}

int find_next(int l, int r){
    int c=0;
    if(l==0){
        c++;
        if(r==1) c++;
    }
    return c;
}

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr);
    cin >> N;
    vector<int> pos(N);
    grid.resize(N,vector<int>(N, 0));
    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < N; j++) grid[i][j]=1;
        cout << "?\n";
        output();
        for (int j = 0; j < N; j++) grid[i][j]=0;
        int base; cin >> base;
        if(base==N*N){
            cout << "!\n";
            for (int j = 0; j < N; j++) grid[i][j]=1;
            output();
            return 0;
        }
        int l=0, r=N-1;
        while(r-l>1){
            int mid=(l+r)/2;
            for (int j = l; j <= mid; j++) grid[i][j]=1;
            cout << "?\n";
            output();
            for (int j = 0; j < N; j++) grid[i][j]=0;
            int res; cin >> res;
            if(res<(mid-l+1)*N) {
                r=mid;
            }else{
                l=mid+1;
            }
        }
        int rnd=find_next(l,r);
        //les deux
        if(l==r) {
            pos[i]=l;
            continue;
        }
        grid[i][l]=1;
        grid[i][r]=1;
        cout << "?\n";
        output();
        int res; cin >> res;
        if(res==N){
            grid[i][l]=0;
            grid[i][r]=0;
            pos[i]=l;
            continue;
        }if(res==2*N){
            grid[i][l]=0;
            grid[i][r]=0;
            pos[i]=r+1;
            continue;
        }
        grid[i][rnd]=1;
        cout << "?\n";
        output();
        cin >> res;
        if(res==N*2-1){
            //vertical
            grid[i][r]=0;
            cout << "?\n";
            output();
            cin >> res;
            if(res==N*2-1) pos[i]=r; 
            else pos[i]=l;
        }else{
            grid[i][r]=0;
            cout << "?\n";
            output();
            cin >> res;
            if(res==N*2-1) pos[i]=l; 
            else pos[i]=r;
        }
        grid[i][rnd]=0;
        grid[i][l]=0;
    }
    for (int i = 0; i < N; i++)
    {
        grid[i][pos[i]]=1;
    }
    cout << "!\n";
    output();
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Runtime error 0 ms 344 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 0 ms 344 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 0 ms 344 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -