Submission #1254052

#TimeUsernameProblemLanguageResultExecution timeMemory
1254052Tenis0206Light Bulbs (EGOI24_lightbulbs)C++20
80 / 100
61 ms432 KiB
#include <bits/stdc++.h>
#define ORIZ 0
#define VERT 1
#define NMAX 100

using namespace std;

vector<pair<int,int>> l[2];
int n, g;
int a[NMAX+1][NMAX+1];
int px[NMAX+1], py[NMAX+1];

bool cmp2( pair<int,int> p1, pair<int, int> p2 ) {
    return p1.second > p2.second;
}

void f2( int l1, int c1, int l2, int c2 ) {
    cout << "?\n";
    for( int i = 1; i <= n; i++ ) {
        for( int j = 1; j <= n; j++ ) {
            if( ( i == l1 && j == c1 ) || ( i == l2 && j == c2 ) )
                cout << 1;
            else
                cout << 0;
        }
        cout << '\n';
    }
}

int main() {
    srand(int(time(NULL)));
    random_device rd;
    mt19937 my_rand(rd());
    int no1, no2, no3, no;
    cin >> n;
    for( int i = 1; i <= n; i++ ) {
        px[i] = i; py[i] = i;
    }
    shuffle( px + 1, px + n + 1, my_rand );
    shuffle( py + 1, py + n + 1, my_rand );
    //(1,1)
    f2( px[1], py[1], px[1], py[2] );
    cin >> no1;
    f2( px[1], py[1], px[1], py[3] );
    cin >> no2;
    f2( px[1], py[2], px[1], py[3] );
    cin >> no3;
    
    if( no1 == n || no2 == n ) g = ORIZ;
    else if( no1 == 2 * n || no2 == 2 * n ) g = VERT;
    else if( no3 == n ) g = VERT;
    else g = ORIZ;
    
    int x = px[1], y = py[1], xx = 2, yy = 2;
    if( g == ORIZ ) {
        x = px[xx++];
        l[ORIZ].push_back( { px[1], py[1] } );
    }
    else {
        y = py[yy++];
        l[VERT].push_back( { px[1], py[1] } );
    }
    while( xx <= n + 1 && yy <= n + 1 ) {
        f2( px[1], py[1], x, y );
        cin >> no;
        if( no == 2 * n - 1 ) {
            l[1-g].push_back( { x, y } );
            if( g == ORIZ ) y = py[yy++];
            else x = px[xx++];
        }
        else {
            l[g].push_back( { x, y } );
            if( g == ORIZ ) x = px[xx++];
            else y = py[yy++];
        }
    }
    
    if( xx > n + 1 ) {
        for( auto pr : l[ORIZ] )
            a[pr.first][pr.second] = 1;
    }
    else {
        for( auto pr : l[VERT] )
            a[pr.first][pr.second] = 1;
    }
    cout << "!\n";
    for( int i = 1; i <= n; i++ ) {
        for( int j = 1; j <= n; j++ )
            cout << a[i][j];
        cout << '\n';
    }
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...