题解 | #字母收集#
字母收集
http://www.nowcoder.com/practice/9740ce2df0a04399a5ade1927d34c1e1
using namespace std;
int main()
{
int a =0, b = 0;
cin >> a >> b;
int arr[a][b];
char val_char;
for(int i = 0; i<a; i++)
for(int j=0; j<b; j++)
{
cin>> val_char;
if(val_char=='l')
arr[i][j] = 4;
else if(val_char=='o')
arr[i][j] = 3;
else if(val_char == 'v')
arr[i][j] = 2;
else if(val_char=='e')
arr[i][j] = 1;
else
arr[i][j] = 0;
}
// int vertical[a];
// int horizental[b];
for(int i=1; i<a; i++)
{
arr[i][0] = arr[i-1][0] + arr[i][0];
}
for(int j=1; j<b; j++)
{
arr[0][j] = arr[0][j-1] + arr[0][j];
}
for(int i=1; i<a; i++)
{
for(int j=1; j<b; j++)
{
arr[i][j] = max(arr[i-1][j], arr[i][j-1])+ arr[i][j];
}
}
cout << arr[a-1][b-1] << endl;
return 0;
}