# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
93945 | ahmedie404 | Pohlepko (COCI16_pohlepko) | C++14 | 1086 ms | 66560 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |