제출 #42878

#제출 시각아이디문제언어결과실행 시간메모리
42878kinssang보물 찾기 (CEOI13_treasure2)C++14
컴파일 에러
0 ms0 KiB
int sum[105][105]; bool check[105][105]; void proc(int r1, int r2, int c1, int c2, int ans) { if (r1 == 1 && c1 == 1) { sum[r2][c2] = ans; check[r2][c2] = true; } if (ans == 0) { for (int i = r1; i <= r2; i++) { for (int j = c1; j <= c2; j++) { sum[i][j] = sum[i-1][j] + sum[i][j-1] - sum[i-1][j-1]; check[i][j] = true; } } } else if (ans == (r2 - r1 + 1)*(c2 - c1 + 1)) { for (int i = r1; i <= r2; i++) { for (int j = c1; j <= c2; j++) { sum[i][j] = sum[i-1][j] + sum[i][j-1] - sum[i-1][j-1] + 1; check[i][j] = true; } } } else { if (!check[(r1+r2)/2][(c1+c2)/ 2]) { sum[(r1+r2)/2][(c1+c2)/2] = ((r1+r2)/2 == 0 || (c1+c2)/2 == 0) ? 0 : countTreasure(1, 1,(r1+r2)/2, (c1+c2)/2); check[(r1+r2)/2][(c1+c2)/2] = true; } if (!check[r2][(c1+c2)/2]) { sum[r2][(c1+c2)/2] = (r2 == 0 || (c1+c2)/2 == 0) ? 0 : countTreasure(1, 1, r2, (c1+c2)/2); check[r2][(c1+c2)/2] = true; } if (!check[(r1+r2)/2][c2]) { sum[(r1+r2)/2][c2] = ((r1+r2)/2 == 0 || c2 == 0) ? 0 : countTreasure(1, 1, (r1+r2)/2, c2); check[(r1+r2)/2][c2] = true; } if(r1 <= (r1+r2)/2 && c1 <= (c1+c2)/2) proc(r1, (r1+r2)/ 2, c1, (c1+c2)/2, sum[(r1+r2)/2][(c1+c2)/2] - sum[r1-1][(c1+c2)/2] - sum[(r1+r2)/2][c1-1] + sum[r1-1][c1-1]); if((r1+r2)/2+1 <= r2 && c1 <= (c1+c2)/2) proc((r1+r2)/2+1, r2, c1, (c1+c2)/2, sum[r2][(c1+c2)/2] - sum[(r1+r2)/2][(c1+c2)/2] - sum[r2][c1-1] + sum[(r1+r2)/2][c1-1]); if(r1 <= (r1+r2)/2 && (c1+c2)/2+1 <= c2) proc(r1, (r1+r2)/2, (c1+c2)/2+1, c2, sum[(r1+r2)/2][c2] - sum[(r1+r2)/2][(c1+c2)/2] - sum[r1-1][c2] + sum[r1-1][(c1+c2)/2]); if((r1+r2)/2+1 <= r2 && (c1+c2)/2+1 <= c2) proc((r1+r2)/2+1, r2, (c1+c2)/2+1, c2, sum[r2][c2] - sum[r2][(c1+c2)/2] - sum[(r1+r2)/2][c2] + sum[(r1+r2)/2][(c1+c2)/2]); } } void findTreasure(int N) { for (int i = 0; i < 105; i++) check[0][i] = true; for (int i = 1; i < 105; i++) check[i][0] = true; int cnt = countTreasure(1, 1, N, N); proc(1, N, 1, N, cnt); for (int i = 1; i <= N; i++) { for (int j = 1; j <= N; j++) { if (sum[i][j] - sum[i][j - 1] - sum[i - 1][j] + sum[i - 1][j - 1] == 1) Report(i, j); } } }

컴파일 시 표준 에러 (stderr) 메시지

grader.c: In function 'int main()':
grader.c:63:34: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         my_assert(strlen(A[i]+1) == N, "each line of the map must contain N zeroes or ones (before loop)");
                                  ^
treasure.cpp: In function 'void proc(int, int, int, int, int)':
treasure.cpp:38:112: error: 'countTreasure' was not declared in this scope
    sum[(r1+r2)/2][(c1+c2)/2] = ((r1+r2)/2 == 0 || (c1+c2)/2 == 0) ? 0 : countTreasure(1, 1,(r1+r2)/2, (c1+c2)/2);
                                                                                                                ^
treasure.cpp:43:92: error: 'countTreasure' was not declared in this scope
    sum[r2][(c1+c2)/2] = (r2 == 0 || (c1+c2)/2 == 0) ? 0 : countTreasure(1, 1, r2, (c1+c2)/2);
                                                                                            ^
treasure.cpp:48:92: error: 'countTreasure' was not declared in this scope
    sum[(r1+r2)/2][c2] = ((r1+r2)/2 == 0 || c2 == 0) ? 0 : countTreasure(1, 1, (r1+r2)/2, c2);
                                                                                            ^
treasure.cpp: In function 'void findTreasure(int)':
treasure.cpp:67:36: error: 'countTreasure' was not declared in this scope
  int cnt = countTreasure(1, 1, N, N);
                                    ^
treasure.cpp:75:87: error: 'Report' was not declared in this scope
    if (sum[i][j] - sum[i][j - 1] - sum[i - 1][j] + sum[i - 1][j - 1] == 1) Report(i, j);
                                                                                       ^