Submission #292886

# Submission time Handle Problem Language Result Execution time Memory
292886 2020-09-07T14:36:32 Z 문홍윤(#5817) Express 20/19 (ROI19_express) C++17
0 / 100
5 ms 512 KB
#include <bits/stdc++.h>
#define mp make_pair
#define eb emplace_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define svec(x) sort(all(x))
#define press(x) x.erase(unique(all(x)), x.end());
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<int, LL> pil;
typedef pair<LL, int> pli;
typedef pair<LL, LL> pll;
const int INF=1e9;
const LL LLINF=1e18;
const LL mod=998244353;

int n, m, k;
LL dp[2010][2010][2], val[1010][1010], ans;
bool ch[2010][2010];

int main(){
    scanf("%d %d %d", &n, &m, &k);
    for(int i=1; i<=k; i++){
        int a, b;
        scanf("%d %d", &a, &b);
        ch[a][b]=true;
        scanf("%lld", &val[a][b]);
    }
    for(int i=n; i>=1; i--){
        for(int j=m; j>=1; j--){
            if(ch[i][j]){
                dp[i][j][1]=dp[i][j][2]=val[i][j];
                continue;
            }
            dp[i][j][1]=min(dp[i+1][j][2], dp[i][j+1][2]);
            dp[i][j][2]=max(dp[i+1][j][1], dp[i][j+1][1]);
        }
    }
    for(int i=1; i<=n; i++){
        for(int j=1; j<=m; j++){
            ans+=dp[i][j][1]+2*mod;
            ans%=mod;
        }
    }
    printf("%lld", ans);
}

Compilation message

express.cpp: In function 'int main()':
express.cpp:24:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   24 |     scanf("%d %d %d", &n, &m, &k);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
express.cpp:27:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   27 |         scanf("%d %d", &a, &b);
      |         ~~~~~^~~~~~~~~~~~~~~~~
express.cpp:29:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   29 |         scanf("%lld", &val[a][b]);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~
express.cpp:37:56: warning: array subscript 2 is above array bounds of 'LL [2]' {aka 'long long int [2]'} [-Warray-bounds]
   37 |             dp[i][j][1]=min(dp[i+1][j][2], dp[i][j+1][2]);
      |                                            ~~~~~~~~~~~~^
express.cpp:37:41: warning: array subscript 2 is above array bounds of 'LL [2]' {aka 'long long int [2]'} [-Warray-bounds]
   37 |             dp[i][j][1]=min(dp[i+1][j][2], dp[i][j+1][2]);
      |                             ~~~~~~~~~~~~^
express.cpp:38:23: warning: array subscript 2 is above array bounds of 'LL [2]' {aka 'long long int [2]'} [-Warray-bounds]
   38 |             dp[i][j][2]=max(dp[i+1][j][1], dp[i][j+1][1]);
      |             ~~~~~~~~~~^
express.cpp:34:39: warning: array subscript 2 is above array bounds of 'LL [2]' {aka 'long long int [2]'} [-Warray-bounds]
   34 |                 dp[i][j][1]=dp[i][j][2]=val[i][j];
      |                             ~~~~~~~~~~^
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 5 ms 512 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 5 ms 512 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 5 ms 512 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 5 ms 384 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 5 ms 384 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -