답안 #824513

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
824513 2023-08-14T07:16:05 Z 반딧불(#10358) 로봇 골프 (ROI19_golf) C++17
0 / 100
108 ms 39484 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[6102][6102][2];
bool hole[6102][6102];
vector<int> vx, vy;
bool blankX[6102], blankY[6102];

void renumber(){
    vx.push_back(1), vx.push_back((n+1)/2);
    for(int i=1; i<=k; i++){
        int x = (px[i] + 1) / 2;
        if(x>1) vx.push_back(x-1);
        vx.push_back(x);
        if(x<(n+1)/2) vx.push_back(x+1);
    }
    vy.push_back(1), vy.push_back((m+1)/2);
    for(int i=1; i<=k; i++){
        int y = (py[i] + 1) / 2;
        if(y>1) vy.push_back(y-1);
        vx.push_back(y);
        if(y<(m+1)/2) vy.push_back(y+1);
    }
    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:52:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   52 |     scanf("%d %d %d", &n, &m, &k);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
golf.cpp:54:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   54 |         scanf("%d %d %lld", &px[i], &py[i], &pc[i]);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Incorrect 1 ms 340 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 72 ms 6328 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Incorrect 1 ms 340 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 108 ms 6044 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 108 ms 6044 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Incorrect 1 ms 340 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 24 ms 39484 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Incorrect 1 ms 340 KB Output isn't correct
5 Halted 0 ms 0 KB -