# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
105946 | leonarda | Pohlepko (COCI16_pohlepko) | C++14 | 1078 ms | 25612 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
const int maxn = 2000 + 5;
int n, m;
char a[maxn][maxn];
string fuki(string t1, string t2) {
for(int i = 0; i < t1.size(); ++i) {
if(t1[i] < t2[i]) return t1;
if(t2[i] < t1[i]) return t2;
}
return t1;
}
string solve(int x, int y, string dosad) {
if(x == n - 1 and y == m - 1)
return dosad;
else if(x == n - 1 and y != m - 1)
return solve(x, y + 1, dosad + a[x][y + 1]);
else if(x != n - 1 and y == m - 1)
return solve(x + 1, y, dosad + a[x + 1][y]);
else if(x != n - 1 and y != m - 1 and a[x + 1][y] < a[x][y + 1])
return solve(x + 1, y, dosad + a[x + 1][y]);
else if(x != n - 1 and y != m - 1 and a[x][y + 1] < a[x + 1][y])
return solve(x, y + 1, dosad + a[x][y + 1]);
else
return fuki(solve(x, y + 1, dosad + a[x][y + 1]), solve(x + 1, y, dosad + a[x + 1][y]));
}
int main ()
{
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin >> n >> m;
for(int i = 0; i < n; ++i)
for(int j = 0; j < m; ++j)
cin >> a[i][j];
string geez; geez.pb(a[0][0]);
cout << solve(0, 0, geez);
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |