My solution doesn't work, I saw that lots of submissions use Dijkstra but I think this might work as well but I can't find the bug
Spoiler
#include <bits/stdc++.h>
#define FOR(i, n) for(ll i=0;i<n;i++)
#define endl '\n'
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define iamspeed() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define tf 200010
#define llcinmz(n, m, z) ll n,m,z;cin>>n>>m>>z
#define pb push_back
ll MOD = 1e9 + 7;
vector<vector<pair<int,ll>>>adj(tf);
vector<bool>vis(tf,0);
int n,m;
ll dp[tf][4];
void dfs(int node)
{
if(node==n)
{
dp[node][0]=0;
dp[node][1]=1;
dp[node][2]=0;
dp[node][3]=0;
return;
}
if(vis[node]) return;
vis[node]=1;
for(auto [child,w] : adj[node])
{
dfs(child);
if(dp[child][1])
{
dp[node][0] = min(dp[child][0]+w, dp[node][0]);
}
}
for(auto [child,w] : adj[node])
{
if(dp[node][0] == dp[child][0]+w)
{
dp[node][1]+=(dp[child][1]%MOD);
dp[node][1]%=MOD;
dp[node][2]= min( dp[node][2] , dp[child][2]);
dp[node][3] = max( dp[node][3] , dp[child][3]);
}
}
dp[node][2]++;
dp[node][3]++;
}
void TT() {
FOR(i,tf) {
dp[i][0]=1e12;
dp[i][1]=0;
dp[i][2] = 1e12;
dp[i][3] = - 1e12;
}
cin>>n>>m;
FOR(i,m)
{
llcinmz(t1,t2,w);
adj[t1].pb({t2,w});
}
dfs(1);
cout<<dp[1][0]<<" "<<dp[1][1]%MOD<<" "
<<dp[1][2]<<" "<<dp[1][3];
}
int main() {
iamspeed()
int t;
// cin >> t;
t = 1;
while (t--) {
TT();
if (t)cout << endl;
}
return 0;
}