제출 #94859

#제출 시각아이디문제언어결과실행 시간메모리
94859rhdmstjr보물 찾기 (CEOI13_treasure2)C++11
44 / 100
2 ms376 KiB
#include "treasure.h" #include <vector> using namespace std; #define MAX_N 104 int pSum[MAX_N][MAX_N]; // [1, 100] bool isTreasure(int r, int c) { return pSum[r][c] - pSum[r-1][c] - pSum[r][c-1] + pSum[r-1][c-1]; } int n; void initPSum() { // init pSum // 일단은 한 방향 + 최적화 없이 pSum[n][n] = countTreasure(1, 1, n, n); for(int i = 1; i <= n; i++) { if (i < (1 + n) / 2) { pSum[i][n] = pSum[n][n] - countTreasure(i + 1, 1, n, n); pSum[n][i] = pSum[n][n] - countTreasure(1, i + 1, n, n); } else { pSum[i][n] = countTreasure(1, 1, i, n); pSum[n][i] = countTreasure(1, 1, n, i); } } for(int r = 1; r < n; r++) { for(int c = 1; c < n; c++) { pSum[r][c] = countTreasure(r + 1, c + 1, n, n) + pSum[r][n] + pSum[n][c] - pSum[n][n]; } } } void findTreasure (int N) { n = N; initPSum(); for(int r = 1; r <= N; r++) { for(int c = 1; c <= N; c++) { if (isTreasure(r, c)) { Report(r, c); } } } }
#Verdict Execution timeMemoryGrader output
Fetching results...