#include #include #include #include using namespace std; using i64 = long long; struct edge { int from, to; i64 cost; }; vector G0, rG; vector cost0, rcost; vector seen; int main(void) { constexpr int inf = 100; int n, m; scanf("%d%d", &n, &m); int a, b; i64 c; for(int i=0; i cost0[e.from] + e.cost) { cost0[e.to] = cost0[e.from] + e.cost; update = true; } } if(!update) { break; } } rcost.assign(n, inf); rcost[n-1] = 0; while(true) { bool update = false; for(int i=0; i rcost[e.from] + e.cost) { rcost[e.to] = rcost[e.from] + e.cost; update = true; } } if(!update) { break; } } int days = -cost0[n-1]; for(int i=0; i