What does this question mean? I 've been reading for half a year, and it's messy.
The memory-based search is dragging. DP [I] [0] indicates the starting point of the ship with the minimum value as the target, DP [I] [1] indicates that the starting point of the ship whose maximum value is obtained is "I", and the starting point of the violent enumeration entry is "0", and the memory-based search is started,
const int N = 100000 + 55;int dp[N][2];int value[N];int degree[N];vector<int> G[N];int n,m,f;void init() {memset(dp,-1,sizeof(dp));memset(value,0,sizeof(value));memset(degree,0,sizeof(degree));for(int i=0;i<N;i++)G[i].clear();}bool input() {while(cin>>n>>m>>f) {for(int i=1;i<=n;i++)scanf("%d",&value[i]);int q = m;while(q--) {int u,v;scanf("%d %d",&u,&v);G[u].push_back(v);degree[v]++;}return false;} return true;}int dfs(int pos,int mark) {if(dp[pos][mark&1] != -1)return dp[pos][mark&1];if(G[pos].size() == 0)return dp[pos][mark&1] = value[pos];dp[pos][mark&1] = 0;int maxn = -1,minn = inf;for(int i=0;i<G[pos].size();i++) {int v = G[pos][i];if(mark&1)maxn = max(maxn,dfs(v,mark + 1));else minn = min(minn,dfs(v,mark + 1));}int tmp = (mark&1)?maxn:minn;return dp[pos][mark&1] = value[pos] + tmp;}void cal() {int ans = -1;for(int i=1;i<=n;i++) {if(degree[i] == 0)ans = max(ans,dfs(i,1));}if(ans < f)puts("Glory");else puts("Victory");}void output() {}int main() {while(true) {init();if(input())return 0;cal();output();}return 0;}
Hdu2452 Navy maneuvers memory-based search