# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
40777 | hsb154 | Treasure (different grader from official contest) (CEOI13_treasure2) | C++14 | 2 ms | 624 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 countTreasure(int r1, int c1, int r2, int c2);
void Report(int r, int c);
bool map[101][101];
void bSearch(int r1,int c1,int r2,int c2,int cnt) {
if (r1 == r2&&c1 == c2) {
map[r1][c2] = 1;
return;
}
int rmid = (r1 + r2) / 2;
int cmid = (c1 + c2) / 2;
int cnt1 = 0, cnt2 = 0, cnt3 = 0, cnt4 = 0;
if (r1 <= rmid&&c1 <= cmid) {//왼쪽 위
cnt1 = countTreasure(r1, c1, rmid, cmid);
if(cnt1!=0)
bSearch(r1, c1, rmid, cmid,cnt1);
}
if (rmid + 1 <= r2&&c1 <= cmid&&cnt!=cnt1) {//왼쪽아래
cnt2 = countTreasure(rmid + 1, c1, r2, cmid);
if(cnt2!=0)
bSearch(rmid + 1, c1, r2, cmid,cnt2);
}
if (r1 <= rmid&&cmid + 1 <= c2&&cnt!=cnt1+cnt2) {//오른쪽 위
cnt3 = countTreasure(r1, cmid + 1, rmid, c2);
if(cnt3!=0)
bSearch(r1, cmid + 1, rmid, c2,cnt3);
}
if (rmid + 1 <= r2&&cmid + 1 <= c2) {//오른쪽 아래
cnt4 = cnt - cnt1 - cnt2 - cnt3;
if(cnt4!=0)
bSearch(rmid + 1, cmid + 1, r2, c2,cnt4);
}
}
void findTreasure (int N) {
int cnt = countTreasure(1, 1, N, N);
bSearch(1,1,N,N,cnt);
for (int i = 1; i <= N; i++) {
for (int j = 1; j <= N; j++) {
if (map[i][j] == 1)
Report(i, j);
}
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |