# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
245128 | TadijaSebez | Treasure (different grader from official contest) (CEOI13_treasure2) | C++11 | 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>
using namespace std;
#define pii pair<int,int>
map<array<int,4>,int> was;
int cnt=0,n;
int Ask(int xl,int yl,int xr,int yr){
if(was.count({{xl,yl,xr,yr}}))return was[{xl,yl,xr,yr}];
printf("%i %i %i %i\n",xl,yl,xr,yr);
fflush(stdout);
int b;scanf("%i",&b);
was[{xl,yl,xr,yr}]=b;
return b;
}
const int N=105;
int sum[N][N],ans[N][N];
int main(){
scanf("%i",&n);
int m=n/2;
for(int i=m+1+1;i<=n;i++)
for(int j=m+1+1;j<=n;j++)
ans[i][j]=Ask(1,1,i,j)-Ask(1,1,i-1,j)-Ask(1,1,i,j-1)+Ask(1,1,i-1,j-1);
for(int i=m+1+1;i<=n;i++)
for(int j=1;j<=m;j++)
ans[i][j]=Ask(1,j,i,n)-Ask(1,j+1,i,n)-Ask(1,j,i-1,n)+Ask(1,j+1,i-1,n);
for(int i=1;i<=m;i++)
for(int j=m+1+1;j<=n;j++)
ans[i][j]=Ask(i,1,n,j)-Ask(i+1,1,n,j)-Ask(i,1,n,j-1)+Ask(i+1,1,n,j-1);
for(int i=1;i<=m;i++)
for(int j=1;j<=m;j++)
ans[i][j]=Ask(i,j,n,n)-Ask(i+1,j,n,n)-Ask(i,j+1,n,n)+Ask(i+1,j+1,n,n);
for(int i=1;i<=m;i++){
ans[i][m+1]=Ask(i,1,n,n)-Ask(i+1,1,n,n);
for(int j=1;j<=n;j++)if(j!=m+1)ans[i][m+1]-=ans[i][j];
}
for(int i=n;i>m+1;i--){
ans[i][m+1]=Ask(1,1,i,n)-Ask(1,1,i-1,n);
for(int j=1;j<=n;j++)if(j!=m+1)ans[i][m+1]-=ans[i][j];
}
for(int j=1;j<=m;j++){
ans[m+1][j]=Ask(1,j,n,n)-Ask(1,j+1,n,n);
for(int i=1;i<=n;i++)if(i!=m+1)ans[m+1][j]-=ans[i][j];
}
for(int j=n;j>m+1;j--){
ans[m+1][j]=Ask(1,1,n,j)-Ask(1,1,n,j-1);
for(int i=1;i<=n;i++)if(i!=m+1)ans[m+1][j]-=ans[i][j];
}
ans[m+1][m+1]=Ask(1,1,n,n);
for(int i=1;i<=n;i++)for(int j=1;j<=n;j++)if(i!=m+1||j!=m+1)ans[m+1][m+1]-=ans[i][j];
printf("END\n");
for(int i=1;i<=n;i++){
for(int j=1;j<=n;j++)printf("%i",ans[i][j]);
printf("\n");
}
fflush(stdout);
return 0;
}