답안 #864392

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
864392 2023-10-22T17:04:17 Z gutzzy Pohlepko (COCI16_pohlepko) C++14
40 / 80
86 ms 65536 KB
#include <bits/stdc++.h>
using namespace std;

int n;
int m;
string ans;
vector<vector<char>> board;
vector<vector<string>> dp;

string calc(int i, int j){
    if(dp[i][j]!="-1") return dp[i][j];
    dp[i][j] = board[i][j] + min(calc(i+1,j),calc(i,j+1));
    return dp[i][j];
}

int main()
{
    cin >> n >> m;
    board = vector<vector<char>>(n,vector<char>(m));
    dp = vector<vector<string>>(n,vector<string>(m, "-1"));


    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            cin >> board[i][j];
        }
    }  
    
    dp[n-1][m-1] = board[n-1][m-1];
    
    string s = "";
    for(int j=m-1;j>=0;j--){
        s=board[n-1][j]+s;
        dp[n-1][j] = s;
    }
    
    s = "";
    for(int i=n-1;i>=0;i--){
        s=board[i][m-1]+s;
        dp[i][m-1] = s;
    }
    
    cout << calc(0,0) << endl;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 604 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 600 KB Output is correct
5 Correct 4 ms 4952 KB Output is correct
6 Runtime error 58 ms 65536 KB Execution killed with signal 9
7 Runtime error 80 ms 65536 KB Execution killed with signal 9
8 Runtime error 32 ms 65536 KB Execution killed with signal 9
9 Correct 2 ms 1116 KB Output is correct
10 Correct 19 ms 18524 KB Output is correct
11 Runtime error 49 ms 65536 KB Execution killed with signal 9
12 Runtime error 62 ms 65536 KB Execution killed with signal 9
13 Runtime error 50 ms 65536 KB Execution killed with signal 9
14 Runtime error 33 ms 65536 KB Execution killed with signal 9
15 Correct 4 ms 2908 KB Output is correct
16 Runtime error 86 ms 65536 KB Execution killed with signal 9