#include <bits/stdc++.h>
using namespace std;
void debug(const char *msg, ...) {
#ifdef CLESIP
va_list arg;
static char pbString[512];
va_start(arg, msg);
vsprintf(pbString, msg, arg);
cerr << "[DEBUG] " << pbString << "\n";
va_end(arg);
#endif
}
using i64 = long long;
const int N = 1010;
const i64 P = 998244353;
bool v[N][N];
int a[N][N], n, m, k, f[N][N][2];
int main() {
ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
cin >> n >> m >> k;
for (int i = 1, x, y; i <= k; i ++) {
cin >> x >> y;
cin >> a[x][y];
v[x][y] = true;
}
for (int i = n; i >= 1; i --) {
for (int j = m; j >= 1; j --) {
if (v[i][j]) {
f[i][j][0] = f[i][j][1] = a[i][j];
} else {
f[i][j][0] = min(f[i + 1][j][1], f[i][j + 1][1]);
f[i][j][1] = max(f[i + 1][j][0], f[i][j + 1][0]);
}
}
}
i64 ans = 0;
for (int i = 1; i <= n; i ++) {
for (int j = 1; j <= m; j ++) {
ans = (ans + f[i][j][0] % P + P) % P;
}
}
cout << ans;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
4444 KB |
Output is correct |
2 |
Correct |
1 ms |
4444 KB |
Output is correct |
3 |
Correct |
1 ms |
4444 KB |
Output is correct |
4 |
Correct |
1 ms |
4444 KB |
Output is correct |
5 |
Correct |
1 ms |
4444 KB |
Output is correct |
6 |
Correct |
1 ms |
4444 KB |
Output is correct |
7 |
Correct |
1 ms |
4444 KB |
Output is correct |
8 |
Correct |
1 ms |
4444 KB |
Output is correct |
9 |
Correct |
8 ms |
12888 KB |
Output is correct |
10 |
Correct |
29 ms |
15128 KB |
Output is correct |
11 |
Correct |
26 ms |
15016 KB |
Output is correct |
12 |
Correct |
31 ms |
14932 KB |
Output is correct |
13 |
Correct |
26 ms |
14936 KB |
Output is correct |
14 |
Correct |
23 ms |
12236 KB |
Output is correct |
15 |
Correct |
26 ms |
15060 KB |
Output is correct |
16 |
Correct |
1 ms |
4444 KB |
Output is correct |
17 |
Correct |
2 ms |
11244 KB |
Output is correct |
18 |
Correct |
2 ms |
4700 KB |
Output is correct |
19 |
Correct |
3 ms |
11356 KB |
Output is correct |
20 |
Correct |
1 ms |
4440 KB |
Output is correct |
21 |
Correct |
2 ms |
10332 KB |
Output is correct |
22 |
Correct |
25 ms |
15032 KB |
Output is correct |
23 |
Correct |
28 ms |
15132 KB |
Output is correct |
24 |
Correct |
26 ms |
15132 KB |
Output is correct |
25 |
Correct |
26 ms |
15044 KB |
Output is correct |
26 |
Correct |
25 ms |
14932 KB |
Output is correct |
27 |
Correct |
25 ms |
15192 KB |
Output is correct |
28 |
Correct |
1 ms |
4440 KB |
Output is correct |
29 |
Correct |
1 ms |
4444 KB |
Output is correct |
30 |
Correct |
1 ms |
4696 KB |
Output is correct |
31 |
Correct |
3 ms |
10076 KB |
Output is correct |
32 |
Correct |
22 ms |
13652 KB |
Output is correct |
33 |
Correct |
23 ms |
14940 KB |
Output is correct |
34 |
Correct |
18 ms |
11916 KB |
Output is correct |
35 |
Correct |
17 ms |
11860 KB |
Output is correct |
36 |
Correct |
17 ms |
11864 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
4440 KB |
Output is correct |
2 |
Correct |
1 ms |
4440 KB |
Output is correct |
3 |
Incorrect |
5 ms |
4444 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
19 ms |
6748 KB |
Output is correct |
2 |
Runtime error |
2 ms |
4700 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
4444 KB |
Output is correct |
2 |
Correct |
1 ms |
4444 KB |
Output is correct |
3 |
Correct |
1 ms |
4444 KB |
Output is correct |
4 |
Correct |
1 ms |
4444 KB |
Output is correct |
5 |
Correct |
1 ms |
4444 KB |
Output is correct |
6 |
Correct |
1 ms |
4444 KB |
Output is correct |
7 |
Correct |
1 ms |
4444 KB |
Output is correct |
8 |
Correct |
1 ms |
4444 KB |
Output is correct |
9 |
Correct |
8 ms |
12888 KB |
Output is correct |
10 |
Correct |
29 ms |
15128 KB |
Output is correct |
11 |
Correct |
26 ms |
15016 KB |
Output is correct |
12 |
Correct |
31 ms |
14932 KB |
Output is correct |
13 |
Correct |
26 ms |
14936 KB |
Output is correct |
14 |
Correct |
23 ms |
12236 KB |
Output is correct |
15 |
Correct |
26 ms |
15060 KB |
Output is correct |
16 |
Correct |
1 ms |
4444 KB |
Output is correct |
17 |
Correct |
2 ms |
11244 KB |
Output is correct |
18 |
Correct |
2 ms |
4700 KB |
Output is correct |
19 |
Correct |
3 ms |
11356 KB |
Output is correct |
20 |
Correct |
1 ms |
4440 KB |
Output is correct |
21 |
Correct |
2 ms |
10332 KB |
Output is correct |
22 |
Correct |
25 ms |
15032 KB |
Output is correct |
23 |
Correct |
28 ms |
15132 KB |
Output is correct |
24 |
Correct |
26 ms |
15132 KB |
Output is correct |
25 |
Correct |
26 ms |
15044 KB |
Output is correct |
26 |
Correct |
25 ms |
14932 KB |
Output is correct |
27 |
Correct |
25 ms |
15192 KB |
Output is correct |
28 |
Correct |
1 ms |
4440 KB |
Output is correct |
29 |
Correct |
1 ms |
4444 KB |
Output is correct |
30 |
Correct |
1 ms |
4696 KB |
Output is correct |
31 |
Correct |
3 ms |
10076 KB |
Output is correct |
32 |
Correct |
22 ms |
13652 KB |
Output is correct |
33 |
Correct |
23 ms |
14940 KB |
Output is correct |
34 |
Correct |
18 ms |
11916 KB |
Output is correct |
35 |
Correct |
17 ms |
11860 KB |
Output is correct |
36 |
Correct |
17 ms |
11864 KB |
Output is correct |
37 |
Runtime error |
3 ms |
4700 KB |
Execution killed with signal 11 |
38 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
2 ms |
4696 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
2 ms |
4696 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
4444 KB |
Output is correct |
2 |
Correct |
1 ms |
4444 KB |
Output is correct |
3 |
Correct |
1 ms |
4444 KB |
Output is correct |
4 |
Correct |
1 ms |
4444 KB |
Output is correct |
5 |
Correct |
1 ms |
4444 KB |
Output is correct |
6 |
Correct |
1 ms |
4444 KB |
Output is correct |
7 |
Correct |
1 ms |
4444 KB |
Output is correct |
8 |
Correct |
1 ms |
4444 KB |
Output is correct |
9 |
Correct |
8 ms |
12888 KB |
Output is correct |
10 |
Correct |
29 ms |
15128 KB |
Output is correct |
11 |
Correct |
26 ms |
15016 KB |
Output is correct |
12 |
Correct |
31 ms |
14932 KB |
Output is correct |
13 |
Correct |
26 ms |
14936 KB |
Output is correct |
14 |
Correct |
23 ms |
12236 KB |
Output is correct |
15 |
Correct |
26 ms |
15060 KB |
Output is correct |
16 |
Correct |
1 ms |
4444 KB |
Output is correct |
17 |
Correct |
2 ms |
11244 KB |
Output is correct |
18 |
Correct |
2 ms |
4700 KB |
Output is correct |
19 |
Correct |
3 ms |
11356 KB |
Output is correct |
20 |
Correct |
1 ms |
4440 KB |
Output is correct |
21 |
Correct |
2 ms |
10332 KB |
Output is correct |
22 |
Correct |
25 ms |
15032 KB |
Output is correct |
23 |
Correct |
28 ms |
15132 KB |
Output is correct |
24 |
Correct |
26 ms |
15132 KB |
Output is correct |
25 |
Correct |
26 ms |
15044 KB |
Output is correct |
26 |
Correct |
25 ms |
14932 KB |
Output is correct |
27 |
Correct |
25 ms |
15192 KB |
Output is correct |
28 |
Correct |
1 ms |
4440 KB |
Output is correct |
29 |
Correct |
1 ms |
4444 KB |
Output is correct |
30 |
Correct |
1 ms |
4696 KB |
Output is correct |
31 |
Correct |
3 ms |
10076 KB |
Output is correct |
32 |
Correct |
22 ms |
13652 KB |
Output is correct |
33 |
Correct |
23 ms |
14940 KB |
Output is correct |
34 |
Correct |
18 ms |
11916 KB |
Output is correct |
35 |
Correct |
17 ms |
11860 KB |
Output is correct |
36 |
Correct |
17 ms |
11864 KB |
Output is correct |
37 |
Correct |
19 ms |
6748 KB |
Output is correct |
38 |
Runtime error |
2 ms |
4700 KB |
Execution killed with signal 11 |
39 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
2 ms |
4696 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
4444 KB |
Output is correct |
2 |
Correct |
1 ms |
4444 KB |
Output is correct |
3 |
Correct |
1 ms |
4444 KB |
Output is correct |
4 |
Correct |
1 ms |
4444 KB |
Output is correct |
5 |
Correct |
1 ms |
4444 KB |
Output is correct |
6 |
Correct |
1 ms |
4444 KB |
Output is correct |
7 |
Correct |
1 ms |
4444 KB |
Output is correct |
8 |
Correct |
1 ms |
4444 KB |
Output is correct |
9 |
Correct |
8 ms |
12888 KB |
Output is correct |
10 |
Correct |
29 ms |
15128 KB |
Output is correct |
11 |
Correct |
26 ms |
15016 KB |
Output is correct |
12 |
Correct |
31 ms |
14932 KB |
Output is correct |
13 |
Correct |
26 ms |
14936 KB |
Output is correct |
14 |
Correct |
23 ms |
12236 KB |
Output is correct |
15 |
Correct |
26 ms |
15060 KB |
Output is correct |
16 |
Correct |
1 ms |
4444 KB |
Output is correct |
17 |
Correct |
2 ms |
11244 KB |
Output is correct |
18 |
Correct |
2 ms |
4700 KB |
Output is correct |
19 |
Correct |
3 ms |
11356 KB |
Output is correct |
20 |
Correct |
1 ms |
4440 KB |
Output is correct |
21 |
Correct |
2 ms |
10332 KB |
Output is correct |
22 |
Correct |
25 ms |
15032 KB |
Output is correct |
23 |
Correct |
28 ms |
15132 KB |
Output is correct |
24 |
Correct |
26 ms |
15132 KB |
Output is correct |
25 |
Correct |
26 ms |
15044 KB |
Output is correct |
26 |
Correct |
25 ms |
14932 KB |
Output is correct |
27 |
Correct |
25 ms |
15192 KB |
Output is correct |
28 |
Correct |
1 ms |
4440 KB |
Output is correct |
29 |
Correct |
1 ms |
4444 KB |
Output is correct |
30 |
Correct |
1 ms |
4696 KB |
Output is correct |
31 |
Correct |
3 ms |
10076 KB |
Output is correct |
32 |
Correct |
22 ms |
13652 KB |
Output is correct |
33 |
Correct |
23 ms |
14940 KB |
Output is correct |
34 |
Correct |
18 ms |
11916 KB |
Output is correct |
35 |
Correct |
17 ms |
11860 KB |
Output is correct |
36 |
Correct |
17 ms |
11864 KB |
Output is correct |
37 |
Correct |
19 ms |
6748 KB |
Output is correct |
38 |
Runtime error |
2 ms |
4700 KB |
Execution killed with signal 11 |
39 |
Halted |
0 ms |
0 KB |
- |