Submission #824570

# Submission time Handle Problem Language Result Execution time Memory
824570 2023-08-14T07:50:14 Z 박영우(#10362) Robogolf (ROI19_golf) C++17
20 / 100
90 ms 65200 KB
#include <bits/stdc++.h>
#include <cassert>
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx,avx2,fma")
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
#define MAX 2020
#define MAXS 20
#define INF 1000000010
#define bb ' '
#define ln '\n'
#define Ln '\n'
#define MOD 998244353
int dp[MAX][MAX];
int mp[MAX][MAX];
signed main() {
	ios::sync_with_stdio(false), cin.tie(0);
	int N, M, K;
	cin >> N >> M >> K;
	int i, j;
	int a, b, c;
	for (i = 1; i <= N; i++) for (j = 1; j <= M; j++) mp[i][j] = INF;
	for (i = 1; i <= K; i++) {
		cin >> a >> b >> c;
		mp[a][b] = c;
	}
	ll sum = 0;
	for (i = N; i >= 1; i--) for (j = M; j >= 1; j--) {
		if (mp[i][j] < INF) {
			dp[i][j] = mp[i][j];
			sum += dp[i][j];
			sum %= MOD;
			continue;
		}
		int p1, p2;
		if (mp[i + 1][j] < INF) p1 = mp[i + 1][j];
		else p1 = max(dp[i + 2][j], dp[i + 1][j + 1]);
		if (mp[i][j + 1] < INF) p2 = mp[i][j + 1];
		else p2 = max(dp[i][j + 2], dp[i + 1][j + 1]);
		dp[i][j] = min(p1, p2);
		sum += dp[i][j];
		sum %= MOD;
	}
	if (sum < 0) sum += MOD;
	cout << sum;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 14 ms 16124 KB Output is correct
10 Correct 32 ms 16040 KB Output is correct
11 Correct 32 ms 16044 KB Output is correct
12 Correct 32 ms 16044 KB Output is correct
13 Correct 33 ms 16036 KB Output is correct
14 Correct 25 ms 8236 KB Output is correct
15 Correct 26 ms 12244 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 3 ms 8276 KB Output is correct
18 Correct 2 ms 468 KB Output is correct
19 Correct 5 ms 8404 KB Output is correct
20 Correct 1 ms 468 KB Output is correct
21 Correct 3 ms 8404 KB Output is correct
22 Correct 35 ms 16020 KB Output is correct
23 Correct 32 ms 16044 KB Output is correct
24 Correct 31 ms 16064 KB Output is correct
25 Correct 31 ms 16116 KB Output is correct
26 Correct 33 ms 16040 KB Output is correct
27 Correct 38 ms 16032 KB Output is correct
28 Correct 0 ms 340 KB Output is correct
29 Correct 0 ms 340 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 3 ms 8336 KB Output is correct
32 Correct 25 ms 9084 KB Output is correct
33 Correct 28 ms 13660 KB Output is correct
34 Correct 17 ms 5796 KB Output is correct
35 Correct 16 ms 5504 KB Output is correct
36 Correct 18 ms 5244 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Incorrect 4 ms 468 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 18 ms 1112 KB Output is correct
2 Runtime error 41 ms 33356 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 14 ms 16124 KB Output is correct
10 Correct 32 ms 16040 KB Output is correct
11 Correct 32 ms 16044 KB Output is correct
12 Correct 32 ms 16044 KB Output is correct
13 Correct 33 ms 16036 KB Output is correct
14 Correct 25 ms 8236 KB Output is correct
15 Correct 26 ms 12244 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 3 ms 8276 KB Output is correct
18 Correct 2 ms 468 KB Output is correct
19 Correct 5 ms 8404 KB Output is correct
20 Correct 1 ms 468 KB Output is correct
21 Correct 3 ms 8404 KB Output is correct
22 Correct 35 ms 16020 KB Output is correct
23 Correct 32 ms 16044 KB Output is correct
24 Correct 31 ms 16064 KB Output is correct
25 Correct 31 ms 16116 KB Output is correct
26 Correct 33 ms 16040 KB Output is correct
27 Correct 38 ms 16032 KB Output is correct
28 Correct 0 ms 340 KB Output is correct
29 Correct 0 ms 340 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 3 ms 8336 KB Output is correct
32 Correct 25 ms 9084 KB Output is correct
33 Correct 28 ms 13660 KB Output is correct
34 Correct 17 ms 5796 KB Output is correct
35 Correct 16 ms 5504 KB Output is correct
36 Correct 18 ms 5244 KB Output is correct
37 Runtime error 48 ms 65200 KB Execution killed with signal 11
38 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 90 ms 65080 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 90 ms 65080 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 14 ms 16124 KB Output is correct
10 Correct 32 ms 16040 KB Output is correct
11 Correct 32 ms 16044 KB Output is correct
12 Correct 32 ms 16044 KB Output is correct
13 Correct 33 ms 16036 KB Output is correct
14 Correct 25 ms 8236 KB Output is correct
15 Correct 26 ms 12244 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 3 ms 8276 KB Output is correct
18 Correct 2 ms 468 KB Output is correct
19 Correct 5 ms 8404 KB Output is correct
20 Correct 1 ms 468 KB Output is correct
21 Correct 3 ms 8404 KB Output is correct
22 Correct 35 ms 16020 KB Output is correct
23 Correct 32 ms 16044 KB Output is correct
24 Correct 31 ms 16064 KB Output is correct
25 Correct 31 ms 16116 KB Output is correct
26 Correct 33 ms 16040 KB Output is correct
27 Correct 38 ms 16032 KB Output is correct
28 Correct 0 ms 340 KB Output is correct
29 Correct 0 ms 340 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 3 ms 8336 KB Output is correct
32 Correct 25 ms 9084 KB Output is correct
33 Correct 28 ms 13660 KB Output is correct
34 Correct 17 ms 5796 KB Output is correct
35 Correct 16 ms 5504 KB Output is correct
36 Correct 18 ms 5244 KB Output is correct
37 Correct 18 ms 1112 KB Output is correct
38 Runtime error 41 ms 33356 KB Execution killed with signal 11
39 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 49 ms 36580 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 14 ms 16124 KB Output is correct
10 Correct 32 ms 16040 KB Output is correct
11 Correct 32 ms 16044 KB Output is correct
12 Correct 32 ms 16044 KB Output is correct
13 Correct 33 ms 16036 KB Output is correct
14 Correct 25 ms 8236 KB Output is correct
15 Correct 26 ms 12244 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 3 ms 8276 KB Output is correct
18 Correct 2 ms 468 KB Output is correct
19 Correct 5 ms 8404 KB Output is correct
20 Correct 1 ms 468 KB Output is correct
21 Correct 3 ms 8404 KB Output is correct
22 Correct 35 ms 16020 KB Output is correct
23 Correct 32 ms 16044 KB Output is correct
24 Correct 31 ms 16064 KB Output is correct
25 Correct 31 ms 16116 KB Output is correct
26 Correct 33 ms 16040 KB Output is correct
27 Correct 38 ms 16032 KB Output is correct
28 Correct 0 ms 340 KB Output is correct
29 Correct 0 ms 340 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 3 ms 8336 KB Output is correct
32 Correct 25 ms 9084 KB Output is correct
33 Correct 28 ms 13660 KB Output is correct
34 Correct 17 ms 5796 KB Output is correct
35 Correct 16 ms 5504 KB Output is correct
36 Correct 18 ms 5244 KB Output is correct
37 Correct 18 ms 1112 KB Output is correct
38 Runtime error 41 ms 33356 KB Execution killed with signal 11
39 Halted 0 ms 0 KB -