Submission #701745

# Submission time Handle Problem Language Result Execution time Memory
701745 2023-02-22T03:21:07 Z scottchou Maja (COCI18_maja) C++17
11 / 110
4 ms 468 KB
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
int const N = 105;
LL dp[2][N][N];
LL c[N][N];
int dis[4][2] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, m, k, x, y;
    cin >> n >> m >> x >> y >> k;
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= m; j++){
            cin >> c[i][j];
            dp[0][i][j] = -1e18;
        }
    }
    if(k <= 10000){
        bool now = 0;
        dp[0][x][y] = 0;
        while(k--){
            for(int i = 1; i <= n; i++){
                for(int j = 1; j <= n; j++){
                    dp[!now][i][j] = -1e18;
                    for(int s = 0; s < 4; s++){
                        int tox = i + dis[s][0], toy = j +dis[s][1];
                        if(tox > 0 && tox <= n && toy > 0 && toy <= m){
                            dp[!now][i][j] = max(dp[!now][i][j], dp[now][tox][toy]);
                        }
                    }
                    dp[!now][i][j] += c[i][j];
                }
            }
            now = !now;
        }
        cout << dp[now][x][y];
    }
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 328 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 332 KB Output is correct
2 Incorrect 3 ms 340 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 408 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 468 KB Output isn't correct
2 Halted 0 ms 0 KB -