# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
65536 | IvanC | Treasure (different grader from official contest) (CEOI13_treasure2) | C++17 | 3 ms | 720 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"
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 110;
static int matriz[MAXN][MAXN];
void solve(int lx,int rx,int ly,int ry,int divide_x,int cnt){
if(cnt == 0) return;
if((rx - lx + 1)*(ry - ly + 1) == cnt){
for(int i = lx;i<=rx;i++){
for(int j = ly;j <= ry;j++){
matriz[i][j] = 1;
}
}
return;
}
if(divide_x){
int mx = (lx + rx)/2;
int qt = countTreasure(lx,ly,mx,ry);
solve(lx,mx,ly,ry,0,qt);
solve(mx+1,rx,ly,ry,0,cnt - qt);
}
else{
int my = (ly + ry)/2;
int qt = countTreasure(lx,ly,rx,my);
solve(lx,rx,ly,my,1,qt);
solve(lx,rx,my+1,ry,1,cnt - qt);
}
}
void findTreasure(int N){
memset(matriz,0,sizeof(matriz));
int cnt = countTreasure(1, 1, N, N);
solve(1,N,1,N,0,cnt);
for(int i = 1;i<=N;i++){
for(int j = 1;j<=N;j++){
if(matriz[i][j]) Report(i,j);
}
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |