# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
48374 | Extazy | Treasure (different grader from official contest) (CEOI13_treasure2) | C++17 | 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 endl '\n'
using namespace std;
const int N = 107;
int n,all;
char out[N][N];
void print_answer() {
int i,j;
printf("END\n");
fflush(stdout);
for(i=1;i<=n;i++) {
for(j=1;j<=n;j++) {
printf("%c", out[i][j]);
}
printf("\n");
}
fflush(stdout);
}
void fill_all(int r1, int r2, int c1, int c2) {
int i,j;
for(i=r1;i<=r2;i++) {
for(j=c1;j<=c2;j++) {
out[i][j]='1';
}
}
}
int ask(int r1, int r2, int c1, int c2) {
printf("%d %d %d %d\n", r1, c1, r2, c2);
fflush(stdout);
int ans;
scanf("%d", &ans);
return ans;
}
void go(int r1, int r2, int c1, int c2, int all) {
if(all==0) return;
if(all==(r2-r1+1)*(c2-c1+1)) {
fill_all(r1,r2,c1,c2);
return;
}
int mid;
if(r1==r2) {
mid=(c1+c2)/2;
int all2=ask(r1,r2,mid+1,c2),all1=all-all2;
go(r1,r2,c1,mid,all1);
go(r1,r2,mid+1,c2,all2);
}
else if(c1==c2) {
mid=(r1+r2)/2;
int all2=ask(mid+1,r2,c1,c2),all1=all-all2;
go(r1,mid,c1,c2,all1);
go(mid+1,r2,c1,c2,all2);
}
else if(rand()%2==0) {
mid=(c1+c2)/2;
int all2=ask(r1,r2,mid+1,c2),all1=all-all2;
go(r1,r2,c1,mid,all1);
go(r1,r2,mid+1,c2,all2);
}
else {
mid=(r1+r2)/2;
int all2=ask(mid+1,r2,c1,c2),all1=all-all2;
go(r1,mid,c1,c2,all1);
go(mid+1,r2,c1,c2,all2);
}
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int i,j;
scanf("%d", &n);
for(i=1;i<=n;i++) {
for(j=1;j<=n;j++) {
out[i][j]='0';
}
}
all=ask(1,n,1,n);
go(1,n,1,n,all);
print_answer();
return 0;
}