#include #include #include #include using namespace std; using i64 = long long; struct edge { int from, to; i64 cost; bool operator < (const edge& other) const { return make_tuple(from, to, cost) < make_tuple(other.from, other.to, other.cost); } }; vector G0, rG; vector cost0, rcost; int main(void) { constexpr i64 inf = 1; 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; } } i64 days = -cost0[n-1]; int cnt = 0; for(int i=0; i