Submission #1356529

#TimeUsernameProblemLanguageResultExecution timeMemory
1356529sallyLight Bulbs (EGOI24_lightbulbs)C++20
11 / 100
3 ms412 KiB
#include<iostream>
#include<vector>
#include<cstring>
using namespace std;
typedef pair<int,int> pii;
const int mx = 100;
bool arr[mx+1][mx+1];
int N;
int ask(vector<pii> bulbs) {
    cout<<"?\n";
    memset(arr, 0, sizeof(arr));
    for(auto [x, y]:bulbs) arr[x][y] = 1;
    for(int i=1; i<=N; i++) {
        for(int j=1; j<=N; j++) cout<<arr[i][j];
        cout<<endl;
    }
    int res;
    cin>>res;
    return res;
}
void get_answer(vector<pii> bulbs) {
    cout<<"!\n";
    memset(arr, 0, sizeof(arr));
    for(auto [x, y]:bulbs) arr[x][y] = 1;
    for(int i=1; i<=N; i++) {
        for(int j=1; j<=N; j++) cout<<arr[i][j];
        cout<<endl;
    }
}
int main() {
    cin>>N;
    for(int i=1; i<=N; i++) {
        vector<pii> temp3;
        temp3.push_back({i, 1});
        temp3.push_back({i, 2});
        temp3.push_back({i, 3});
        int res1 = ask(temp3);
        if(res1 == N*N) {
            get_answer(temp3);
            return 0;
        }
        vector<pii> temp4;
        temp4.push_back({1, i});
        temp4.push_back({2, i});
        temp4.push_back({3, i});
        int res2 = ask(temp4);
        if(res2 == N*N) {
            get_answer(temp4);
            return 0;
        }
        for(int j=1; j<=N; j++) {
            vector<pii> temp;
            temp.push_back({1, 1});
            temp.push_back({2, i});
            temp.push_back({3, j});
            int res1 = ask(temp);
            if(res1 == N*N) {
                get_answer(temp);
                return 0;
            }
            vector<pii> temp2;
            temp2.push_back({1, 1});
            temp2.push_back({i, 2});
            temp2.push_back({j, 3});
            int res2 = ask(temp2);
            if(res2 == N*N) {
                get_answer(temp2);
                return 0;
            }
        }
    }
}
#Result Execution timeMemoryGrader output
Fetching results...
#Result Execution timeMemoryGrader output
Fetching results...
#Result Execution timeMemoryGrader output
Fetching results...