답안 #824425

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
824425 2023-08-14T06:04:53 Z 이동현(#10361) 로봇 골프 (ROI19_golf) C++17
20 / 100
5000 ms 524288 KB
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#define int long long
using namespace std;

const int mod = 998244353;

signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);

	int n, m, k;
	cin >> n >> m >> k;
	vector<array<int, 3>> a(k);
	for(int i = 0; i < k; ++i){
		cin >> a[i][0] >> a[i][1] >> a[i][2];
		--a[i][0], --a[i][1];
	}

	sort(a.begin(), a.end(), [&](array<int, 3>&x, array<int, 3>&y){return x[0] + x[1] < y[0] + y[1];});

	int ans = 0;
	auto sol = [&](int bt){
		vector<int> dp(n + m), ndp(n + m);

		int ap = k - 1;
		for(int i = n + m - 2; i >= 0; --i){
			for(int j = 0; j < n + m - 1; ++j){
				if(!bt) ndp[j] = min(dp[j], dp[j + 1]);
				else ndp[j] = max(dp[j], dp[j + 1]);
			}
			swap(dp, ndp);

			while(ap >= 0 && a[ap][0] + a[ap][1] == i){
				dp[a[ap][1]] = a[ap][2];
				--ap;
			}

			if(!bt){
				for(int x = 0; x <= i; ++x){
					int y = i - x;
					if(x < n && y < m){
						(ans += dp[y] + mod * 2) %= mod;
					}
				}
			}

			bt ^= 1;
		}
	};
	sol(0);
	sol(1);

	cout << ans << '\n';
	
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 320 KB Output is correct
4 Correct 0 ms 316 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 12 ms 356 KB Output is correct
10 Correct 45 ms 3236 KB Output is correct
11 Correct 44 ms 3236 KB Output is correct
12 Correct 48 ms 3440 KB Output is correct
13 Correct 45 ms 3276 KB Output is correct
14 Correct 37 ms 3268 KB Output is correct
15 Correct 36 ms 3260 KB Output is correct
16 Correct 2 ms 340 KB Output is correct
17 Correct 3 ms 340 KB Output is correct
18 Correct 4 ms 468 KB Output is correct
19 Correct 3 ms 468 KB Output is correct
20 Correct 2 ms 340 KB Output is correct
21 Correct 2 ms 340 KB Output is correct
22 Correct 44 ms 3264 KB Output is correct
23 Correct 42 ms 3284 KB Output is correct
24 Correct 42 ms 3308 KB Output is correct
25 Correct 42 ms 3316 KB Output is correct
26 Correct 42 ms 3312 KB Output is correct
27 Correct 44 ms 3276 KB Output is correct
28 Correct 2 ms 320 KB Output is correct
29 Correct 2 ms 316 KB Output is correct
30 Correct 2 ms 316 KB Output is correct
31 Correct 3 ms 320 KB Output is correct
32 Correct 41 ms 3296 KB Output is correct
33 Correct 39 ms 3224 KB Output is correct
34 Correct 24 ms 3284 KB Output is correct
35 Correct 24 ms 2900 KB Output is correct
36 Correct 25 ms 2896 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 316 KB Output is correct
3 Correct 188 ms 1092 KB Output is correct
4 Execution timed out 5075 ms 5988 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 5017 ms 4300 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 320 KB Output is correct
4 Correct 0 ms 316 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 12 ms 356 KB Output is correct
10 Correct 45 ms 3236 KB Output is correct
11 Correct 44 ms 3236 KB Output is correct
12 Correct 48 ms 3440 KB Output is correct
13 Correct 45 ms 3276 KB Output is correct
14 Correct 37 ms 3268 KB Output is correct
15 Correct 36 ms 3260 KB Output is correct
16 Correct 2 ms 340 KB Output is correct
17 Correct 3 ms 340 KB Output is correct
18 Correct 4 ms 468 KB Output is correct
19 Correct 3 ms 468 KB Output is correct
20 Correct 2 ms 340 KB Output is correct
21 Correct 2 ms 340 KB Output is correct
22 Correct 44 ms 3264 KB Output is correct
23 Correct 42 ms 3284 KB Output is correct
24 Correct 42 ms 3308 KB Output is correct
25 Correct 42 ms 3316 KB Output is correct
26 Correct 42 ms 3312 KB Output is correct
27 Correct 44 ms 3276 KB Output is correct
28 Correct 2 ms 320 KB Output is correct
29 Correct 2 ms 316 KB Output is correct
30 Correct 2 ms 316 KB Output is correct
31 Correct 3 ms 320 KB Output is correct
32 Correct 41 ms 3296 KB Output is correct
33 Correct 39 ms 3224 KB Output is correct
34 Correct 24 ms 3284 KB Output is correct
35 Correct 24 ms 2900 KB Output is correct
36 Correct 25 ms 2896 KB Output is correct
37 Runtime error 343 ms 524288 KB Execution killed with signal 9
38 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 5054 ms 6700 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 5054 ms 6700 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 320 KB Output is correct
4 Correct 0 ms 316 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 12 ms 356 KB Output is correct
10 Correct 45 ms 3236 KB Output is correct
11 Correct 44 ms 3236 KB Output is correct
12 Correct 48 ms 3440 KB Output is correct
13 Correct 45 ms 3276 KB Output is correct
14 Correct 37 ms 3268 KB Output is correct
15 Correct 36 ms 3260 KB Output is correct
16 Correct 2 ms 340 KB Output is correct
17 Correct 3 ms 340 KB Output is correct
18 Correct 4 ms 468 KB Output is correct
19 Correct 3 ms 468 KB Output is correct
20 Correct 2 ms 340 KB Output is correct
21 Correct 2 ms 340 KB Output is correct
22 Correct 44 ms 3264 KB Output is correct
23 Correct 42 ms 3284 KB Output is correct
24 Correct 42 ms 3308 KB Output is correct
25 Correct 42 ms 3316 KB Output is correct
26 Correct 42 ms 3312 KB Output is correct
27 Correct 44 ms 3276 KB Output is correct
28 Correct 2 ms 320 KB Output is correct
29 Correct 2 ms 316 KB Output is correct
30 Correct 2 ms 316 KB Output is correct
31 Correct 3 ms 320 KB Output is correct
32 Correct 41 ms 3296 KB Output is correct
33 Correct 39 ms 3224 KB Output is correct
34 Correct 24 ms 3284 KB Output is correct
35 Correct 24 ms 2900 KB Output is correct
36 Correct 25 ms 2896 KB Output is correct
37 Execution timed out 5017 ms 4300 KB Time limit exceeded
38 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 181 ms 524288 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 320 KB Output is correct
4 Correct 0 ms 316 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 12 ms 356 KB Output is correct
10 Correct 45 ms 3236 KB Output is correct
11 Correct 44 ms 3236 KB Output is correct
12 Correct 48 ms 3440 KB Output is correct
13 Correct 45 ms 3276 KB Output is correct
14 Correct 37 ms 3268 KB Output is correct
15 Correct 36 ms 3260 KB Output is correct
16 Correct 2 ms 340 KB Output is correct
17 Correct 3 ms 340 KB Output is correct
18 Correct 4 ms 468 KB Output is correct
19 Correct 3 ms 468 KB Output is correct
20 Correct 2 ms 340 KB Output is correct
21 Correct 2 ms 340 KB Output is correct
22 Correct 44 ms 3264 KB Output is correct
23 Correct 42 ms 3284 KB Output is correct
24 Correct 42 ms 3308 KB Output is correct
25 Correct 42 ms 3316 KB Output is correct
26 Correct 42 ms 3312 KB Output is correct
27 Correct 44 ms 3276 KB Output is correct
28 Correct 2 ms 320 KB Output is correct
29 Correct 2 ms 316 KB Output is correct
30 Correct 2 ms 316 KB Output is correct
31 Correct 3 ms 320 KB Output is correct
32 Correct 41 ms 3296 KB Output is correct
33 Correct 39 ms 3224 KB Output is correct
34 Correct 24 ms 3284 KB Output is correct
35 Correct 24 ms 2900 KB Output is correct
36 Correct 25 ms 2896 KB Output is correct
37 Execution timed out 5017 ms 4300 KB Time limit exceeded
38 Halted 0 ms 0 KB -