# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
470563 | nicolaalexandra | Treasure (different grader from official contest) (CEOI13_treasure2) | C++14 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define DIM 110
using namespace std;
int a[DIM][DIM];
int n,i,j;
int query (int x, int y, int x2, int y2){
cout<<x<<" "<<y<<" "<<x2<<" "<<y2<<endl;
int ans;
cin>>ans;
return ans;
}
void solve (int x, int y, int x2, int y2, int cnt){
if (x > x2 || y > y2 || !cnt)
return;
if (cnt == (x2-x+1) * (y2-y+1)){
for (int i=x;i<=x2;i++)
for (int j=y;j<=y2;j++)
a[i][j] = 1;
return;
}
int midx = (x+x2)>>1, midy = (y+y2)>>1;
int val1 = query (x,y,midx,midy);
solve (x,y,midx,midy,val1);
if (midy+1 <= y2){
int val2 = query (x,midy+1,midx,y2);
solve (x,midy+1,midx,y2,val2);
}
if (midx+1 <= x2){
int val3 = query (midx+1,y,x2,midy);
solve (midx+1,y,x2,midy,val3);
}
if (midx+1 <= x2 && midy+1 <= y2){
int val4 = query (midx+1,midy+1,x2,y2);
solve (midx+1,midy+1,x2,y2,val4);
}
}
int main (){
cin>>n;
solve (1,1,n,n,query(1,1,n,n));
cout<<"END\n";
for (i=1;i<=n;i++,cout<<"\n")
for (j=1;j<=n;j++)
cout<<a[i][j];
return 0;
}