#include <bits/stdc++.h>
using namespace std;
long long n, m;
string word, path;
char unos[2000][2000];
int main (){
ios::sync_with_stdio(0);
cin.tie(0);
cin >> n >> m;
for (int i=0;i<n;i++){
cin >> word;
for(int j=0;j<m;j++){
unos[i][j] = word[j];
}
}
path = unos[0][0];
int i=0, j=0;
while (i!=n-1 and j!=m-1){
if (unos[i][j+1] > unos[i+1][j]){
i++;
path = path + unos[i][j];
}
else{
j++;
path = path + unos[i][j];
}
}
while (i!=n-1){
i++;
path = path + unos[i][j];
}
while (j!=m-1){
j++;
path = path + unos[i][j];
}
cout << path;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
3 ms |
1408 KB |
Output is correct |
3 |
Correct |
2 ms |
1408 KB |
Output is correct |
4 |
Correct |
2 ms |
1408 KB |
Output is correct |
5 |
Correct |
3 ms |
1408 KB |
Output is correct |
6 |
Correct |
4 ms |
1408 KB |
Output is correct |
7 |
Correct |
8 ms |
4856 KB |
Output is correct |
8 |
Correct |
14 ms |
10000 KB |
Output is correct |
9 |
Incorrect |
2 ms |
10000 KB |
Output isn't correct |
10 |
Incorrect |
3 ms |
10000 KB |
Output isn't correct |
11 |
Incorrect |
4 ms |
10000 KB |
Output isn't correct |
12 |
Incorrect |
6 ms |
10000 KB |
Output isn't correct |
13 |
Incorrect |
6 ms |
10740 KB |
Output isn't correct |
14 |
Incorrect |
15 ms |
14676 KB |
Output isn't correct |
15 |
Incorrect |
3 ms |
14676 KB |
Output isn't correct |
16 |
Incorrect |
10 ms |
15292 KB |
Output isn't correct |