#include<bits/stdc++.h>
using namespace std;
#define fast ios::sync_with_stdio(false); cin.tie(0);
#define fi first
#define se second
#define em emplace
#define eb emplace_back
#define mp make_pair
#define all(v) (v).begin(), (v).end()
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ll, pll> plll;
const int inf = 1e9;
const ll INF = 1e18;
int n, m;
int u[300010];
int v[300010];
ll w[300010];
ll a[300010];
vector<pll> g[300010];
int dp[300010];
int d[300010];
bool chk[300010];
int ans = inf;
void dfs(int x, int p) {
chk[x] = true;
dp[x] = d[x];
for(auto i : g[x]) {
if(i.se == p) continue;
if(chk[i.fi]) {
dp[x] = min(dp[x], d[i.fi]);
continue;
}
d[i.fi] = d[x] + 1;
dfs(i.fi, i.se);
dp[x] = min(dp[x], dp[i.fi]);
}
if(p && dp[x] >= d[x]) {
ans = min(ans, p);
}
dp[x] = min(mn, dp[x]);
}
int main() {
fast;
cin >> n >> m;
for(int i=1; i<=m; i++) {
cin >> u[i] >> v[i] >> w[i];
g[u[i]].eb(v[i], i);
g[v[i]].eb(u[i], i);
}
for(int i=m; i > 1; i--) {
a[i-1] = max(a[i], w[i]);
}
dfs(1, 0);
memset(chk, 0, sizeof(chk));
queue<int> q;
q.em(1);
chk[1] = true;
while(q.size()) {
int x = q.front();
q.pop();
for(auto i : g[x]) {
if(chk[i.fi]) continue;
chk[i.fi] = true;
d[i.fi] = d[x] + 1;
q.em(i.fi);
}
}
cout << d[n] + (ans < m);
}
Compilation message
Aesthetic.cpp: In function 'void dfs(int, int)':
Aesthetic.cpp:53:14: error: 'mn' was not declared in this scope; did you mean 'm'?
53 | dp[x] = min(mn, dp[x]);
| ^~
| m