답안 #824552

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
824552 2023-08-14T07:35:20 Z 반딧불(#10358) 로봇 골프 (ROI19_golf) C++17
0 / 100
489 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][1200002][2];
bool hole[10][1200002];
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]);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 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 0 ms 340 KB Output is correct
7 Runtime error 3 ms 436 KB Execution killed with signal 11
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 17 ms 1740 KB Output is correct
4 Correct 100 ms 12620 KB Output is correct
5 Correct 179 ms 97492 KB Output is correct
6 Incorrect 240 ms 141196 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 91 ms 10116 KB Output is correct
2 Runtime error 41 ms 4564 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 0 ms 340 KB Output is correct
7 Runtime error 3 ms 436 KB Execution killed with signal 11
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 110 ms 10576 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 110 ms 10576 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 0 ms 340 KB Output is correct
7 Runtime error 3 ms 436 KB Execution killed with signal 11
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 489 ms 524288 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 0 ms 340 KB Output is correct
7 Runtime error 3 ms 436 KB Execution killed with signal 11
8 Halted 0 ms 0 KB -