제출 #1347541

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

int n;

int ask(vector<pair<int, int>> v){

  cout << "?" << endl;

  vector<vector<int>> mat(n, vector<int> (n, 0));

  for(auto [x, y] : v) mat[x][y] = 1;

  for(int i=0; i<n; i++){
    for(int j=0; j<n; j++){
      cout << mat[i][j];
    }
    cout << endl;
  }

  int ans; cin >> ans;
  return ans;

}

void answer(vector<pair<int, int>> v){

  cout << "!" << endl;

  vector<vector<int>> mat(n, vector<int> (n, 0));

  for(auto [x, y] : v) mat[x][y] = 1;

  for(int i=0; i<n; i++){
    for(int j=0; j<n; j++){
      cout << mat[i][j];
    }
    cout << endl;
  }

}

vector<pair<int, int>> col(int j, int i){

  vector<pair<int, int>> ret;

  for(int k=0; k<=i; k++) ret.push_back({j, k});
  return ret;

}

int main(){
  cin.tie(0)->sync_with_stdio(0);

  cin >> n;

  for(int mask=0; mask<(1 << (n * n)); mask++){

    int sz = __builtin_popcount(mask);

    if(sz != n) continue;

    vector<pair<int, int>> to_ask;

    for(int i=0; i<n; i++){
      for(int j=0; j<n; j++){
        if(mask & (1 << (i + j * n))){
          to_ask.push_back({i, j});
        }
      }
    }

    if(ask(to_ask) == n * n){
      answer(to_ask);
      return 0;
    }

  }


  return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...