#include using namespace std; typedef unsigned int uint; typedef long long int ll; typedef unsigned long long int ull; #define debugv(v) printf("L%d %s => ",__LINE__,#v);for(auto e:v){cout< ",__LINE__,#m);for(int x=0;x<(w);x++){cout<<(m)[x]<<" ";}cout<>=1,k++)s=(s<<1)|(u&1);for(;0>=1)cout<<(s&1);}} #define TIME chrono::system_clock::now() #define MILLISEC(t) (chrono::duration_cast(t).count()) template ostream& operator <<(ostream &o,const pair p){o<<"("<> vertex[100010]; vector> vertex_rev[100010]; ll dpc[100010]; ll dpl[100010]; ll dp2[100010]; ll dph[100010]; int main(){ int i,j,k; int x,y,a,b; cin>>n>>m; for (i=0;i> q; q.push(vector{0}); while (!q.empty()){ vector& vref = q.front(); from = vref[0]; q.pop(); for (auto p : vertex[from]){ to = p.first; cost = p.second; dpl[to] = max(dpl[to],dpl[from]+cost); dpc[to]++; if (dpc[to]==vertex_rev[to].size()) q.push(vector{to}); } } fill(dpc,dpc+n,0); fill(dph,dph+n,E107); dph[n-1] = dpl[n-1]; q.push(vector{n-1}); while (!q.empty()){ vector& vref = q.front(); from = vref[0]; q.pop(); //if (dpc[from]!=vertex[from].size()) continue; //dpc[from]++; for (auto p : vertex_rev[from]){ to = p.first; cost = p.second; //printf("%d<-%d %d\n",from,to,vertex[from].size()); dph[to] = min(dph[to],dph[from]-cost); dpc[to]++; if (dpc[to]==vertex[to].size()) q.push(vector{to}); } } int work=1; for (i=1;i