#include <bits/stdc++.h>
using namespace std;
int main()
{
/* hacer una dp bidimensional en la que se pondra la solucion lexicograficamente menor en cada casilla*/
int x, y;
cin>> x >> y;
vector<vector<char>> tab(x, vector<char>(y));
vector<vector<string>> dp (x, vector<string>(y));
for (int i = 0; i < x; ++i){
for (int j = 0; j < y; ++j){
cin>> tab[i][j];
}
}
dp[0][0] = tab[0][0];
for (int i = 1; i < x; ++i)dp[i][0] = dp[i-1][0] + tab[i][0];
for (int j = 1; j < y; ++j)dp[0][j] = dp[0][j-1] + tab[0][j];
for (int i = 1; i < x; ++i){
for (int j = 1; j <y ; ++j){
dp[i][j] = min(dp[i-1][j], dp[i][j-1])+ tab[i][j];
}
}
cout<< dp[x-1][y-1] << '\n';
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
604 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
604 KB |
Output is correct |
5 |
Correct |
4 ms |
8540 KB |
Output is correct |
6 |
Runtime error |
38 ms |
65536 KB |
Execution killed with signal 9 |
7 |
Runtime error |
70 ms |
65536 KB |
Execution killed with signal 9 |
8 |
Runtime error |
29 ms |
65536 KB |
Execution killed with signal 9 |
9 |
Correct |
1 ms |
1372 KB |
Output is correct |
10 |
Correct |
23 ms |
33420 KB |
Output is correct |
11 |
Runtime error |
34 ms |
65536 KB |
Execution killed with signal 9 |
12 |
Runtime error |
45 ms |
65536 KB |
Execution killed with signal 9 |
13 |
Runtime error |
37 ms |
65536 KB |
Execution killed with signal 9 |
14 |
Runtime error |
27 ms |
65536 KB |
Execution killed with signal 9 |
15 |
Correct |
4 ms |
4700 KB |
Output is correct |
16 |
Runtime error |
77 ms |
65536 KB |
Execution killed with signal 9 |