# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
824551 |
2023-08-14T07:34:13 Z |
반딧불(#10358) |
Robogolf (ROI19_golf) |
C++17 |
|
492 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][800002][2];
bool hole[10][800002];
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<=3; 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 |
1 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 |
1 ms |
304 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 |
3 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 |
14 ms |
2124 KB |
Output is correct |
4 |
Correct |
80 ms |
14476 KB |
Output is correct |
5 |
Correct |
143 ms |
81568 KB |
Output is correct |
6 |
Incorrect |
174 ms |
96612 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
71 ms |
7816 KB |
Output is correct |
2 |
Runtime error |
40 ms |
6408 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 |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
304 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 |
3 ms |
468 KB |
Execution killed with signal 11 |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
87 ms |
7852 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
87 ms |
7852 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 |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
304 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 |
3 ms |
468 KB |
Execution killed with signal 11 |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
492 ms |
524288 KB |
Execution killed with signal 9 |
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 |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
304 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 |
3 ms |
468 KB |
Execution killed with signal 11 |
8 |
Halted |
0 ms |
0 KB |
- |