#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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
436 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
11 ms |
920 KB |
Output is correct |
7 |
Correct |
44 ms |
2900 KB |
Output is correct |
8 |
Correct |
126 ms |
8236 KB |
Output is correct |
9 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
10 |
Incorrect |
2 ms |
444 KB |
Output isn't correct |
11 |
Incorrect |
4 ms |
608 KB |
Output isn't correct |
12 |
Incorrect |
12 ms |
1116 KB |
Output isn't correct |
13 |
Incorrect |
7 ms |
860 KB |
Output isn't correct |
14 |
Incorrect |
134 ms |
8244 KB |
Output isn't correct |
15 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
16 |
Incorrect |
52 ms |
3540 KB |
Output isn't correct |