# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
40800 | meylady | Treasure (different grader from official contest) (CEOI13_treasure2) | C++14 | 1097 ms | 262144 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 <stdio.h>
int Map[104][104];
void fill(int r1, int c1, int r2, int c2, int cnt) {
for (int i = r1; i <= r2; i++) {
for (int j = c1; j <= c2; j++) {
Map[i][j] = cnt;
}
}
}
void search(int r1, int c1, int r2, int c2, int cnt) {
//printf("%d %d %d %d\n", r1, c1, r2, c2);
if ((r1 == r2) && (c1==c2))return;
if (r2-r1 == c2-c1) {//정사각형 가로로 자르기
int mid = (c1 + c2) / 2;
int num = countTreasure(r1, c1, r2, mid);
fill(r1, c1, r2, mid, num);
fill(r1, mid + 1, r2, c2, cnt - num);
search(r1, c1, r2, mid, num);
search(r1, mid + 1, r2, c2, cnt -num);
}
else { //세로로 자르기
int mid = (r1 + r2) / 2;
int num = countTreasure(r1, c1, mid, c2);
fill(r1, c1, mid, c2, num);
fill(mid + 1, c1, r2, c2, cnt - num);
search(r1, c1, mid, c2, num);
search(mid + 1,c1, r2, c2, cnt - num);
}
}
void findTreasure (int N) {
int cnt = countTreasure(1, 1, N, N);
fill(1, 1, N, N, cnt);
search(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... |