Los solution to a problem Valley P1004 [access] grid

Luo Gu Linked: https://www.luogu.com.cn/blog/jvruo-0076/solutiun-p1004
this question in fact it, that simple is not simpleTo me, That is difficult is not difficultFor you.
In fact, this problem is to allow you to find the best value. I.e.
~~~
F [I] [J] [L] [K] = max (max (F [I -. 1] [J] [L -. 1] [K], F [I] [J -. 1] [l] [k-1] ), max (f [i - 1] [j] [l] [k - 1], f [i] [j - 1] [l - 1] [k])) + d [i] [J];
~ ~ ~
this is a problem handling the back of a front how to do it?
~~~
the while (CIN Y >> >> >> S X && X)
D [X] [Y] = S;
~~~
here was not readincluding meWhat is called while (cin >> x >> y >> s && x) it?
Is this:
Here a combination of input, judgment cycle. Means that the input x, y, s, x is determined whether or not 0, if so, is circulated. This is equivalent to
~~~
A123:
CIN X >> >> >> S Y;
IF (X = 0!) // or IF (X)
{
... // (omitted here)
GOTO A123;
}
~~~
What? a123, goto a123; they are what?
Such:
setting a consisting of letters, numbers, names (e.g., a123, kkksc03, zhentanshu666), plus the name used in goto, that part of the program will jump to this latter name.

Note: I do not recommend trial a123, goto a123; such procedures, to avoid some of the problems

For example: the defect evaluation machine results in a compilation error, or not to jump out of the loop. On some review sites, such words would be treated as "non-valid pointer drift"

Well, pull away ...
the final output, the perfect end.

Code

#include<bits/stdc++.h>
using namespace std;
int n, i, j, l, k, x, y, s;
int d[55][55], f[55][55][55][55];
int main() 
{
 cin>>n;
 while(cin>>x>>y>>s && x)
 d[x][y] = s;
 for(i = 1; i <= n; i++)
 for(j = 1; j <= n; j++)
 for(l = 1; l <= n; l++)
 for(k = 1; k <= n; k++) 
 {
  f[i][j][l][k] = max(max(f[i - 1][j][l - 1][k], f[i][j - 1][l][k-1]), max(f[i - 1][j][l][k - 1], f[i][j - 1][l - 1][k])) + d[i][j];
  if(i != 1 && j != k) f[i][j][l][k] += d[l][k];
  }
 printf("%d", f[n][n][n][n]);
 return 0;
}

Finally, he said the sentence:
I hope you thumbs up, follow me!
Good bye!

Guess you like

Origin www.cnblogs.com/107003CN171yunbingche/p/12040490.html