Home > Back-end >  Why this program for a few mistakes?
Why this program for a few mistakes?

Time:12-04





 class Solution {
Public:
Vector Dp, the pre, vis;
Vector Val.
String ans.
Void DFS (int u, int fa, vector & E) {
Vis [u]=1;
For (auto v: e [u]) {
If (n==fa) continue;
If (dp val [u] + [v - 1] & gt; Dp [v]) dp [v]=dp [u] + val - 1 [v], pre [v]=u;
DFS (v, u, e);
}
}
Void Print (int u) {
If (pre [u]==1) {
Ans +=(u + '0');
return;
}
Print (pre [u]);
Ans +="-";
Ans +=(u + '0');
}
String digSum (vector & A, vector & E) {
Int n=a.s considering ();
Val=a;
Dp. The resize (n + 1, 0), pre. Resize (n + 1, 1);
Vis. The resize (n + 1, 0);
for(int i=1; i<=n; I++) dp=[I] a [I - 1);
for(int i=1; i<=n; I++)
if(! Vis [I]) DFS (I, 0, e);
Int id, mx=0;
for(int i=1; i<=n; I++)
If (dp [I] & gt; Mx, mx=dp [I], id=I;
Print (id);
return ans;
}
};


Where is the program for a few mistakes, didn't find out,

CodePudding user response:

Learn the debugging techniques, debugging
  • Related