# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
68667 | Pajaraja | Treasure (different grader from official contest) (CEOI13_treasure2) | C++17 | 3 ms | 692 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;
int t[107][107],n;
void rek(int x1,int y1,int x2,int y2,int k)
{
if(x2<x1 || y2<y1 || x2>n || y2>n) return;
if(k==(x2-x1+1)*(y2-y1+1))
{
for(int i=x1;i<=x2;i++) for(int j=y1;j<=y2;j++) t[i][j]=1;
return;
}
if(k==0)
{
for(int i=x1;i<=x2;i++) for(int j=y1;j<=y2;j++) t[i][j]=0;
return;
}
int sx=(x1+x2)/2,sy=(y1+y2)/2;
int k1=0,k2=0,k3=0;
k1=countTreasure(x1,y1,sx,sy);
if(sy<y2) k2=countTreasure(x1,sy+1,x2,y2);
else k2=k1;
if(sx<x2) k3=countTreasure(sx+1,y1,x2,sy);
rek(x1,y1,sx,sy,k1);
rek(x1,sy+1,sx,y2,k2-k1);
rek(sx+1,y1,x2,sy,k3);
rek(sx+1,sy+1,x2,y2,k-k2-k3);
}
void findTreasure (int N)
{
n=N;
rek(1,1,n,n,countTreasure(1,1,n,n));
for(int i=1;i<=n;i++) for(int j=1;j<=n;j++) if(t[i][j]==1) Report(i,j);
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |