# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1088337 | Rolo678 | Aesthetic (NOI20_aesthetic) | C++14 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define int long long
vector<vector<,pair<int,int>>>g(3e5+5);
vector<long long>dp2(3e5+5,-1);
vector<long long>dp(3e5+5,-1);
signed main()
{
int n,m;
cin >> n>>m;
// cin >> n >> m;
vector<long long>mx(m+2);
for(int i = 1;i<=m;i++)
{
int a,b,w;
cin >> a >> b >> w;
//cout << 'o';
g[a].push_back({b,i});
g[b].push_back({a,i});
mx[i] = w;
//cout << 'o';
}
for(int i = n-1;i> 0;i--)
{
mx[i] = max(mx[i+1],mx[i]);
}
//dfs();
dp[1] =0;
queue<int>q;
q.push_back(1);
while(!q.empty())
{
v = q.top();
q.pop();
for(auto i : g[v])
{
if(dp[u] == -1)
{
q.push(u);
dp[u] = dp[v] + 1;
}
}
}
dp2[n] =0;
queue<int>q;
q.push_back(n);
while(!q.empty())
{
v = q.top();
q.pop();
for(auto i : g[v])
{
if(dp2[u] == -1)
{
q.push(u);
dp2[u] = dp2[v] + 1;
}
}
}
int ans = 0;
cout << ans;
}