Main topic
The Chinese test instructions on the question is too vague ...
Given a topological map, each has a forward edge of two weights, two people from 1 to N, respectively, walk these two weights. Ask if there is a right value so that all two people can walk through these weights to N.
Ideas
After reading the question, it was water. Maintaining two arrays Indicates whether the number from node 1th can reach J through the weight of I. Then do the topology map DP.
CODE
#define _crt_secure_no_warnings#include <queue>#include <cstdio>#include <cstring>#include <iostream>#include <algorithm>#define MAX#define Maxe 10010#define INF 0x3f3f3f3fusing namespace STD;intPoints,edges;intHead[max],total;int_next[maxe],aim[maxe];intLength[maxe],_length[maxe];inline voidADD (intXintYintLenint_len) {_next[++total] = head[x]; Aim[total] = y; Length[total] = len; _length[total] = _len; HEAD[X] = total;}int_in[max]; Queue<int>QBOOLF[max][maxe],g[max][maxe];BOOLV[max];intMain () {Cin>> points >> edges; for(intX,y,z,l,i =1; I <= edges; ++i) {scanf("%d%d%d%d", &x,&y,&z,&l); ADD (x,y,z,l); ++_in[y]; } for(inti =1; I <= points; ++i)if(!_in[i]) Q.push (i); f[1][0] = g[1][0] =true; while(!q.empty ()) {intx = Q.front (); Q.pop (); for(inti = head[x]; I i = _next[i]) { for(intj =0; J + Length[i] < Maxe; ++J) F[aim[i]][j + length[i]] |= f[x][j]; for(intj =0; J + _length[i] < Maxe; ++J) G[aim[i]][j + _length[i]] |= g[x][j];if(!--_in[aim[i]]) Q.push (Aim[i]); } } for(inti =0; i < maxe; ++i)if(F[points][i]&g[points][i]) {cout<< i << Endl;return 0; }puts("Impossible");return 0;}
Bzoj 3890 Usaco2015 Jan meeting time topology DP