#include #include using namespace std; using i64 = long long; constexpr i64 inf = 987654321987654321LL; struct edge { int to; i64 cost; }; vector> fG, rG; vector dp0, dp1; i64 rec0(int v) { i64 &res = dp0[v]; if(res != -1) { return res; } res = 0; for(edge &e : rG[v]) { res = max(res, rec0(e.to) + e.cost); } return res; } i64 rec1(int v) { i64 &res = dp1[v]; if(res != -1) { return res; } res = inf; for(edge &e : fG[v]) { res = min(res, rec1(e.to) - e.cost); } return res; } int main(void) { int n, m; scanf("%d%d", &n, &m); fG.assign(n, vector()); rG.assign(n, vector()); for(int i=0; i