답안 #93945

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
93945 2019-01-13T16:29:50 Z ahmedie404 Pohlepko (COCI16_pohlepko) C++14
45 / 80
1000 ms 66560 KB
#include <iostream>

using namespace std;
int n, m;
string a[2000+9];
bool vis[2000+9][2000+9];

bool check(int i, int j){
    return i >= 0 && j >= 0 && i < n && j < m;
}

string finds(int i, int j, string s){

    char l='z';
    int x,y;

    s += a[i][j];

    if( i == n-1 && j == m-1 )
        return s;

    if(check(i+1, j) && a[i+1][j] <= l){
        l = a[i+1][j];
        x=i+1, y=j;
    }

    if(check(i, j+1) && a[i][j+1] < l){
        l = a[i][j+1];
        x=i, y=j+1;
    }

    if(a[i+1][j] == a[i][j+1]){
        return min(string(finds(i+1, j, s)), string(finds(i, j+1, s)));
        if(string(finds(i+1, j, s)) > string(finds(i, j+1, s))){
            vis[i+1][j]=true;
        } else {
            vis[i][j+1]=true;
        }
    }

    vis[x][y]=true;

    return finds(x, y, s);

}

int main(){
    cin >> n >> m;
    for(int i=0;i<n;i++) cin >> a[i];

    cout << finds(0, 0, "") << endl;

    return 0;
}

Compilation message

pohlepko.cpp: In function 'std::__cxx11::string finds(int, int, std::__cxx11::string)':
pohlepko.cpp:43:25: warning: 'y' may be used uninitialized in this function [-Wmaybe-uninitialized]
     return finds(x, y, s);
                         ^
pohlepko.cpp:43:25: warning: 'x' may be used uninitialized in this function [-Wmaybe-uninitialized]
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 3 ms 1784 KB Output is correct
3 Correct 13 ms 376 KB Output is correct
4 Correct 2 ms 508 KB Output is correct
5 Correct 3 ms 1528 KB Output is correct
6 Correct 10 ms 2684 KB Output is correct
7 Correct 45 ms 11640 KB Output is correct
8 Correct 127 ms 29176 KB Output is correct
9 Correct 14 ms 632 KB Output is correct
10 Execution timed out 1070 ms 1688 KB Time limit exceeded
11 Runtime error 523 ms 66560 KB Execution killed with signal 9 (could be triggered by violating memory limits)
12 Execution timed out 1072 ms 5308 KB Time limit exceeded
13 Execution timed out 1076 ms 9980 KB Time limit exceeded
14 Execution timed out 1078 ms 29432 KB Time limit exceeded
15 Execution timed out 1086 ms 1024 KB Time limit exceeded
16 Execution timed out 1073 ms 27808 KB Time limit exceeded