답안 #659201

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
659201 2022-11-17T01:36:44 Z as111 보물 찾기 (CEOI13_treasure2) C++14
0 / 100
3 ms 748 KB
#include "treasure.h""
#include <iostream>

#define MAXN 100

using namespace std;
int ps[MAXN + 5][MAXN + 5]; // partial sum # treasure
int ans[MAXN + 5][MAXN + 5];
int findTreasure(int N) {
	ps[N][N] = countTreasure(1, 1, N, N);
	for (int r = N; r >= 2; r--) {
		for (int c = N; c >= 2; c--) {
			if (!ps[r][c - 1]) {
				ps[r][c - 1] = countTreasure(1, 1, r, c - 1);
			}
			if (!ps[r - 1][c - 1]) {
				ps[r - 1][c - 1] = countTreasure(1, 1, r - 1, c - 1);
			}
			if (!ps[r - 1][c]) {
				ps[r - 1][c] = countTreasure(1, 1, r - 1, c);
			}
			ans[r][c] = ps[r][c] - ps[r - 1][c] - ps[r][c - 1] + ps[r - 1][c - 1];
		}
	}
	for (int r = N; r >= 1; r--) {
		ans[r][1] = ps[r][2] - ps[r - 1][2] - ans[r][2];
	}
	for (int c = N; c >= 1; c--) {
		ans[1][c] = ps[2][c] - ps[2][c-1] - ans[2][c];
	}

	for (int r = 1; r <= N; r++) {
		for (int c = 1; c <= N; c++) {
			cout << ans[r][c];
		}
		cout << endl;
	}
}

Compilation message

treasure.cpp:1:22: warning: missing terminating " character
    1 | #include "treasure.h""
      |                      ^
treasure.cpp:1:22: warning: extra tokens at end of #include directive
treasure.cpp: In function 'int findTreasure(int)':
treasure.cpp:38:1: warning: no return statement in function returning non-void [-Wreturn-type]
   38 | }
      | ^
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 468 KB Execution killed with signal 11
2 Runtime error 1 ms 468 KB Execution killed with signal 11
3 Runtime error 2 ms 468 KB Execution killed with signal 11
4 Runtime error 1 ms 468 KB Execution killed with signal 11
5 Runtime error 2 ms 596 KB Execution killed with signal 11
6 Runtime error 2 ms 560 KB Execution killed with signal 11
7 Runtime error 2 ms 724 KB Execution killed with signal 11
8 Runtime error 3 ms 748 KB Execution killed with signal 11
9 Runtime error 3 ms 696 KB Execution killed with signal 11
10 Runtime error 2 ms 724 KB Execution killed with signal 11