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>
#define ordered_set tree <ll, null_type, less <ll>, rb_tree_tag, tree_order_statistics_node_update>
#define fast ios_base::sync_with_stdio(0);ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define ull unsigned long long
#define ld long double
#define pf push_front
#define pb push_back
#define ll long long
#define endl "\n"
#define S second
#define F first
#define ff cout.flush();
#define all(x) x.begin(),x.end()
using namespace std;
bool pri (int a)
{
if (a<=1)return 0;
for (int i=2;i*i<=a;i++)
{
if (a%i==0)
{
return 0;
}
}
return 1;
}
ll mod=1000000007;
ll Fastpower(ll x, ll y){
if (y == 0) return 1;
if (y == 1) return x;
ll ret = Fastpower(x, y / 2);
ret = (ret * ret) % mod;
if (y % 2 != 0) ret = (ret * x) % mod;
return ret;
}
ll n,m,a,b,c,o[200000];
vector<pair<ll,pair<ll,ll> > > s;
signed main()
{
fast;
srand(time(NULL));
cin>>n>>m;
ll z=m;
while (z--)
{
cin>>a>>b>>c;
if (b<a)swap(a,b);
s.push_back({a,{b,c}});
o[a]=max(o[a],c);
o[b]=max(o[b],c);
}
sort(all(s));
for (int i=0;i<m;i++)
{
a=s[i].F;
b=s[i].S.F;
c=s[i].S.S;
if (c==o[a])continue;
else o[b]=c;
}
for (int i=1;i<=n;i++)
{
cout<<o[i]<<" ";
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |