Submission #86166

#TimeUsernameProblemLanguageResultExecution timeMemory
86166facelessTreasure (different grader from official contest) (CEOI13_treasure2)C++14
0 / 100
320 ms263168 KiB
#include "treasure.h" bool c[120][120]; int dp[120][120]; int find (int idx, int L, int R, int cnt = -1) { if (cnt == -1) { cnt = countTreasure (1, 1, idx, R - 1) - dp[idx - 1][R - 1] - dp[idx][L - 1] + dp[idx - 1][L - 1]; } if (cnt == (R - L) or cnt == 0) { bool val = (cnt == (R - L)); for (int j = L; j < R; j++) { c[idx][j] = val; dp[idx][j] = c[idx][j] + dp[idx - 1][j] + dp[idx][j - 1] - dp[idx - 1][j - 1]; } return cnt; } int mid = (L + R) >> 1; int x = find (idx, mid, R); find (idx, L, mid, cnt - x); return cnt; } void findTreasure (int N) { for (int i = 1; i <= N; i++) { find (i, 1, N + 1); for (int j = 1; j <= N; j++) { dp[i][j] = c[i][j] + dp[i - 1][j] + dp[i][j - 1] - dp[i - 1][j - 1]; } } for (int i = 1; i <= N; i++) for (int j = 1; j <= N; j++) if (c[i][j]) Report (i, j); }
#Verdict Execution timeMemoryGrader output
Fetching results...