#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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
328 KB |
Output is correct |
3 |
Correct |
1 ms |
328 KB |
Output is correct |
4 |
Correct |
0 ms |
328 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
328 KB |
Output is correct |
3 |
Correct |
1 ms |
328 KB |
Output is correct |
4 |
Correct |
0 ms |
328 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Incorrect |
2 ms |
340 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
328 KB |
Output is correct |
3 |
Correct |
1 ms |
328 KB |
Output is correct |
4 |
Correct |
0 ms |
328 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Incorrect |
2 ms |
340 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
1288 KB |
Output is correct |
2 |
Correct |
13 ms |
2252 KB |
Output is correct |
3 |
Correct |
10 ms |
2252 KB |
Output is correct |
4 |
Correct |
5 ms |
1364 KB |
Output is correct |
5 |
Correct |
1 ms |
468 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
328 KB |
Output is correct |
3 |
Correct |
1 ms |
328 KB |
Output is correct |
4 |
Correct |
0 ms |
328 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Incorrect |
2 ms |
340 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |