# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
4532 | kriii | Treasure (different grader from official contest) (CEOI13_treasure2) | C++98 | 0 ms | 1228 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 "treasure.h"
int R[105][105];
void go(int sx, int sy, int ex, int ey, int count)
{
if (sx > ex || sy > ey) return;
if (count == 0) return;
if ((ex - sx + 1) * (ey - sy + 1) == count){
int i,j;
for (i=sx;i<=ex;i++) for (j=sy;j<=ey;j++) R[i][j] = 1;
return;
}
int m,c;
if (ex - sx >= ey - sy){
m = (ex + sx) / 2;
c = countTreasure(sx,sy,m,ey);
go(sx,sy,m,ey,c);
go(m+1,sy,ex,ey,count-c);
}
else{
m = (ey + sy) / 2;
c = countTreasure(sx,sy,ex,m);
go(sx,sy,ex,m,c);
go(sx,m+1,ex,ey,count-c);
}
}
void findTreasure (int N)
{
int i,j;
for (i=1;i<=N;i++) for (j=1;j<=N;j++) R[i][j] = 0;
go(1,1,N,N,countTreasure(1,1,N,N));
for (i=1;i<=N;i++) for (j=1;j<=N;j++) if(R[i][j] == 1) Report(i, j);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |