# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
824555 |
2023-08-14T07:36:51 Z |
반딧불(#10358) |
Robogolf (ROI19_golf) |
C++17 |
|
481 ms |
524288 KB |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 998244353;
int n, m, k;
int px[100002], py[100002]; ll pc[100002];
ll DP[10][2200002][2];
bool hole[10][2200002];
vector<int> vx, vy;
void renumber(){
for(int i=1; i<=n; i++) vx.push_back((i+1)/2);
vy.push_back(1), vy.push_back((m+1)/2);
for(int i=1; i<=k; i++){
int y = (py[i] + 1) / 2;
for(int a=1; a<=5; a++){
if(y-a>1) vy.push_back(y-a);
if(y+a<(m+1)/2) vy.push_back(y+a);
}
vy.push_back(y);
}
sort(vx.begin(), vx.end()); vx.erase(unique(vx.begin(), vx.end()), vx.end());
sort(vy.begin(), vy.end()); vy.erase(unique(vy.begin(), vy.end()), vy.end());
vector<int> tvx (1, 0), tvy (1, 0);
for(int x: vx){
tvx.push_back(x*2-1);
if(x*2 <= n) tvx.push_back(x*2);
}
for(int y: vy){
tvy.push_back(y*2-1);
if(y*2 <= m) tvy.push_back(y*2);
}
n = (int)tvx.size()-1, m = (int)tvy.size()-1;
vx.swap(tvx), vy.swap(tvy);
for(int i=1; i<=k; i++){
px[i] = lower_bound(vx.begin(), vx.end(), px[i]) - vx.begin();
py[i] = lower_bound(vy.begin(), vy.end(), py[i]) - vy.begin();
}
}
int main(){
scanf("%d %d %d", &n, &m, &k);
for(int i=1; i<=k; i++){
scanf("%d %d %lld", &px[i], &py[i], &pc[i]);
}
renumber();
for(int i=1; i<=k; i++){
DP[px[i]][py[i]][0] = DP[px[i]][py[i]][1] = pc[i];
hole[px[i]][py[i]] = 1;
}
for(int i=n+1; i>=1; i--){
for(int j=m+1; j>=1; j--){
if(i==n+1 || j==m+1){
DP[i][j][0] = DP[i][j][1] = 0;
continue;
}
if(hole[i][j]) continue;
DP[i][j][0] = min(DP[i+1][j][1], DP[i][j+1][1]);
DP[i][j][1] = max(DP[i+1][j][0], DP[i][j+1][0]);
//printf("%d %d: %lld %lld\n", i, j, DP[i][j][0], DP[i][j][1]);
}
}
ll ans = 0;
for(int i=1; i<=n; i++){
for(int j=1; j<=m; j++){
ll v = (DP[i][j][0] + MOD*2) % MOD;
if(i+2 <= n) v = v * ((vx[i+2] - vx[i]) / 2) % MOD;
if(j+2 <= m) v = v * ((vy[j+2] - vy[j]) / 2) % MOD;
//printf("%d %d: %lld\n", i, j, v);
ans = (ans + v) % MOD;
}
}
printf("%lld", ans);
}
Compilation message
golf.cpp: In function 'int main()':
golf.cpp:47:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
47 | scanf("%d %d %d", &n, &m, &k);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
golf.cpp:49:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
49 | scanf("%d %d %lld", &px[i], &py[i], &pc[i]);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
0 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Runtime error |
5 ms |
468 KB |
Execution killed with signal 11 |
8 |
Halted |
0 ms |
0 KB |
- |
# |
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 |
Correct |
16 ms |
1796 KB |
Output is correct |
4 |
Correct |
97 ms |
12760 KB |
Output is correct |
5 |
Correct |
174 ms |
97468 KB |
Output is correct |
6 |
Correct |
299 ms |
204936 KB |
Output is correct |
7 |
Correct |
281 ms |
227664 KB |
Output is correct |
8 |
Correct |
154 ms |
83800 KB |
Output is correct |
9 |
Correct |
213 ms |
120236 KB |
Output is correct |
10 |
Correct |
217 ms |
156788 KB |
Output is correct |
11 |
Correct |
250 ms |
193324 KB |
Output is correct |
12 |
Correct |
291 ms |
230060 KB |
Output is correct |
13 |
Correct |
288 ms |
230004 KB |
Output is correct |
14 |
Correct |
294 ms |
229932 KB |
Output is correct |
15 |
Correct |
138 ms |
51024 KB |
Output is correct |
16 |
Correct |
129 ms |
41784 KB |
Output is correct |
17 |
Correct |
226 ms |
157152 KB |
Output is correct |
18 |
Correct |
156 ms |
59584 KB |
Output is correct |
19 |
Correct |
146 ms |
59612 KB |
Output is correct |
20 |
Correct |
153 ms |
59580 KB |
Output is correct |
21 |
Correct |
1 ms |
596 KB |
Output is correct |
22 |
Correct |
1 ms |
596 KB |
Output is correct |
23 |
Correct |
1 ms |
572 KB |
Output is correct |
24 |
Correct |
0 ms |
340 KB |
Output is correct |
25 |
Correct |
0 ms |
340 KB |
Output is correct |
26 |
Correct |
77 ms |
15136 KB |
Output is correct |
27 |
Correct |
81 ms |
22044 KB |
Output is correct |
28 |
Correct |
63 ms |
11264 KB |
Output is correct |
29 |
Correct |
63 ms |
11320 KB |
Output is correct |
30 |
Correct |
64 ms |
11348 KB |
Output is correct |
31 |
Correct |
66 ms |
11320 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
89 ms |
10176 KB |
Output is correct |
2 |
Runtime error |
52 ms |
4568 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
0 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Runtime error |
5 ms |
468 KB |
Execution killed with signal 11 |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
108 ms |
10596 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
108 ms |
10596 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
0 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Runtime error |
5 ms |
468 KB |
Execution killed with signal 11 |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
481 ms |
524288 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
0 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Runtime error |
5 ms |
468 KB |
Execution killed with signal 11 |
8 |
Halted |
0 ms |
0 KB |
- |