제출 #99043

#제출 시각아이디문제언어결과실행 시간메모리
99043wjdclgns12보물 찾기 (CEOI13_treasure2)C++14
68 / 100
3 ms384 KiB
#include "treasure.h" int cnt = 0; int resultX[10001]; int resultY[10001]; void findFunc(int r1, int c1, int r2, int c2, int trs) { int area = (r2 - r1 + 1) * (c2 - c1 + 1); if (trs == 0) return; if (trs == area) { for (int i = r1; i <= r2; i++) for (int j = c1; j <= c2; j++) { resultX[cnt] = i; resultY[cnt] = j; cnt++; } return; } if (r1 != r2) { int half = countTreasure(r1, c1, (r1 + r2) / 2, c2); findFunc(r1, c1, (r1 + r2) / 2, c2, half); findFunc((r1 + r2) / 2 + 1, c1, r2, c2, trs - half); } else { int half = countTreasure(r1, c1, r2, (c1 + c2) / 2); findFunc(r1, c1, r2, (c1 + c2) / 2, half); findFunc(r1, (c1 + c2) / 2 + 1, r2, c2, trs - half); } return; } void findTreasure(int N) { findFunc(1, 1, N , N, countTreasure(1, 1, N, N)); for (int i = 0; i < cnt; i++) { Report(resultX[i], resultY[i]); } }
#Verdict Execution timeMemoryGrader output
Fetching results...