#include <bits/stdc++.h>
using namespace std;
int32_t main(){
ios::sync_with_stdio(0);
cin.tie(0);
int n;
cin >> n;
int arr[n][n];
for(int i=0; i<n; i++){
for(int j=0; j<n; j++){
arr[i][j]=0;
}
}
int r=0,c=0;
vector<pair<int,int> > vert,hori;
while(r<n&&c<n){
if(r==0&&c==0){
cout << "?" << endl;
for(int i=0; i<n; i++) cout << 1;
cout << endl;
for(int i=1; i<n; i++){
for(int j=0; j<n; j++) cout << 0;
cout << endl;
}
int x;
cin >> x;
cout << "?" << endl;
cout << 0;
for(int i=1; i<n; i++) cout << 1;
cout << endl;
for(int i=1; i<n; i++){
for(int j=0; j<n; j++) cout << 0;
cout << endl;
}
int y;
cin >> y;
if(y==x-1){
hori.push_back({r,c});
r++;
}
else{
vert.push_back({r,c});
c++;
}
}
else if(r){
cout << '?' << endl;
for(int i=0; i<n; i++){
for(int j=0; j<n; j++){
if(i==r&&j==c) cout << 1;
else if(i==hori.back().first&&j==hori.back().second) cout << 1;
else cout << 0;
}
cout << endl;
}
int x;
cin >> x;
if(x==n*2){
hori.push_back({r,c});
r++;
}
else{
assert(x==n*2-1);
vert.push_back({r,c});
c++;
}
}
else{
cout << '?' << endl;
for(int i=0; i<n; i++){
for(int j=0; j<n; j++){
if(i==r&&j==c) cout << 1;
else if(i==vert.back().first&&j==vert.back().second) cout << 1;
else cout << 0;
}
cout << endl;
}
int x;
cin >> x;
if(x==n*2){
vert.push_back({r,c});
c++;
}
else{
assert(x==n*2-1);
hori.push_back({r,c});
r++;
}
}
}
if(r==n){
for(auto i:hori){
arr[i.first][i.second]=1;
}
}
else{
for(auto i:vert){
arr[i.first][i.second]=1;
}
}
cout << '!' << endl;
for(int i=0; i<n; i++){
for(int j=0; j<n; j++) cout << arr[i][j];
cout << endl;
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |