Submission #864346

#TimeUsernameProblemLanguageResultExecution timeMemory
864346gutzzyPohlepko (COCI16_pohlepko)C++14
40 / 80
134 ms8244 KiB
#include <bits/stdc++.h>
using namespace std;

int main(){
    int n,m;
    cin >> n >> m;
    vector<vector<char>> board(n,vector<char>(m));
    
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            cin >> board[i][j];
        }
    }
    
    int i = 0;
    int j = 0;
    string ans;
    ans += board[i][j];
    while(i!=n-1 or j!=m-1){
        if(i==n-1){
            j++;
            ans+=board[i][j];
        }
        else if(j==m-1){
            i++;
            ans+=board[i][j];
        }
        else{
            if(board[i+1][j]<board[i][j+1]){
                i++;
                ans+=board[i][j];
            }
            else{
                j++;
                ans+=board[i][j];
            }
        }
    }
    cout << ans << endl;

    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...