#include #include using namespace std; using namespace atcoder; constexpr long long INF_LL = 2000000000000000000LL; constexpr int INF = 2000000000; constexpr long long MOD = 1000000007; #define all(x) x.begin(), x.end() #define REP(i, a, b) for(int i = a; i < b; i++) #define rep(i, n) REP(i, 0, n) typedef long long ll; typedef pair P; typedef vector vi; typedef vector vvi; typedef vector

vp; typedef vector vl; int dx[4] = {0, -1, 0, 1}; int dy[4] = {1, 0, -1, 0}; int sign[2] = {1, -1}; template bool chmax(T &a, T b) { if(a < b) { a = b; return 1; } return 0; } template bool chmin(T &a, T b) { if(a > b) { a = b; return 1; } return 0; } ll modpow(ll a, ll b, ll m) { if(b == 0) return 1; ll t = modpow(a, b / 2, m); if(b & 1) { return (t * t % m) * a % m; } else { return t * t % m; } } struct edge { int to; ll cost; edge(int t, ll c) { to = t, cost = c; } }; typedef vector> graph; using mint = modint998244353; vector dijkstra(vector> &g, int start, int n) { priority_queue, greater

> que; vector dist(n, INF_LL); dist[start] = 0; que.push(P(0, start)); while(!que.empty()) { P p = que.top(); que.pop(); int v = p.second; if(dist[v] < p.first) continue; rep(i, (int)g[v].size()) { edge e = g[v][i]; if(dist[e.to] > dist[v] + e.cost) { dist[e.to] = dist[v] + e.cost; que.push(P(dist[e.to], e.to)); } } } return dist; } int main(){ cin.tie(0); std::ios_base::sync_with_stdio(false); std::cout << std::fixed << std::setprecision(16); int n, m, k; cin >> n >> m >> k; vector, int>> e(m); rep(i, m){ cin >> e[i].first.first >> e[i].first.second >> e[i].second; } sort(all(e), [](auto &x, auto &y){return x.second < y.second;}); int l = -1, r = 200001; while(r - l > 1){ int md = (l + r) / 2; int idx = 0; graph g(n); while(idx < m and e[idx].second <= md){ g[e[idx].first.first - 1].push_back({e[idx].first.second - 1, 0}); g[e[idx].first.second - 1].push_back({e[idx].first.first - 1, 0}); idx++; } REP(i, idx, m){ g[e[i].first.first - 1].push_back({e[i].first.second - 1, 1}); g[e[i].first.second - 1].push_back({e[i].first.first - 1, 1}); } if((dijkstra(g, 0, n))[n - 1] <= k - 1){ r = md; }else{ l = md; } } cout << r << endl; }