# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
277313 | Marlov | Treasure (different grader from official contest) (CEOI13_treasure2) | C++14 | 1 ms | 384 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.
/*
Code by @marlov
*/
#include "treasure.h"
#define maxN 105
int N;
int grid[maxN][maxN];
void bs(int x1,int y1,int x2,int y2){
if(x1==x2||y1==y2) return;
int num=countTreasure(x1+1,y1+1,x2,y2);
if(num==0) return;
if(x1+1==x2&&y1+1==y2){
grid[x1][y1]=1;
return;
}
if((x2-x1)*(y2-y1)==num){
for(int i=x1;i<x2;i++){
for(int j=y1;j<y2;j++){
grid[i][j]=1;
}
}
return;
}
bs(x1,y1,(x1+x2)/2,(y1+y2)/2);
bs((x1+x2)/2,y1,x2,(y1+y2)/2);
bs(x1,(y1+y2)/2,(x1+x2)/2,y2);
bs((x1+x2)/2,(y1+y2)/2,x2,y2);
}
void findTreasure(int gN){
// ios_base::sync_with_stdio(0); cin.tie(0);
N=gN;
bs(0,0,N,N);
for(int i=0;i<N;i++){
for(int j=0;j<N;j++){
if(grid[i][j]==1) Report(i+1,j+1);
}
}
}
/* stuff you should look for
* int overflow, array bounds
* special cases (n=1,n=0?)
* do smth instead of nothing and stay organized
*/
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |