#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define sp <<' '<<
#define FOR(i,a) for(int i=0;i<(a);i++)
#define FORE(i,a,b) for(int i=(a);i<(b);i++)
#define cont(x) for(auto el:x) cout<<el<<endl;
#define contp(x) for(auto el:x) cout<<el.fi<<'-'<<el.se<<' ';cout<<endl;
#define DEBUG(x) cout<<#x sp x<<endl;
#define mid (l+r)/2
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii> vii;
typedef vector<bool> vb;
signed main(){
ios_base::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
int n;
cin>>n;
vector<string> grid(n);
vector<string> cev(n);
vector<string> res(n);
FOR(i,n){
FOR(j,n){
grid[i]+='0';
cev[i]+='0';
res[i]+='U'; //unknown
}
}
int ans;
grid[0][0]=grid[0][1]='1';
cout<<"?"<<endl;
cont(grid);
cin>>ans;
int x,y;
x=y=0;
int bas=0;
//1-->vert
//2-->horiz
if(ans==2*n){
//both vertical
bas=1;
y+=2;
res[0][0]=res[0][1]='V';
}
else if(ans==n){
//both horizontal
bas=2;
x+=2;
res[0][0]=res[0][1]='H';
}
else{
x++;y++;
int tut;
FOR(i,n) grid[0][i]='1';
cout<<'?'<<endl;
cont(grid);
cin>>tut;
grid[0][0]='0';
cout<<'?'<<endl;
cont(grid);
cin>>ans;
if(ans==tut-(n-1)){
bas=1;
res[0][0]='V';
res[0][1]='H';
}
else{
bas=2;
res[0][0]='V';
res[0][1]='H';
}
}
if(bas==1) res[0][0]='V';
else res[0][0]='H';
while(x<n and y<n){
//sifirla
FOR(i,n){
FOR(j,n){
grid[i][j]='0';
}
}
grid[0][0]='1';
grid[x][y]='1';
cout<<"?"<<endl;
cont(grid);
cin>>ans;
if(ans==2*n){
//both same direction
res[x][y]=res[0][0];
if(bas==1) y++;
else x++;
}
else{
//both different direction
res[x][y]=(res[0][0]=='V'?'H':'V');
if(bas==1) x++;
else y++;
}
}
//cont(res);
bool f=false;
FOR(i,n){
f=false;
FOR(j,n){
if(res[i][j]=='H'){
f=true;
break;
}
}
if(!f) break;
}
if(!f){
FOR(i,n){
FOR(j,n){
if(res[j][i]=='V'){
cev[j][i]='1';
break;
}
}
}
}
else{
FOR(i,n){
bool f=false;
FOR(j,n){
if(res[i][j]=='H'){
cev[i][j]='1';
break;
}
}
}
}
cout<<"!"<<endl;
cont(cev);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |