Submission #945034

#TimeUsernameProblemLanguageResultExecution timeMemory
945034dsyzLost Array (NOI19_lostarray)C++17
100 / 100
34 ms10496 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; #define MAXN (1000005) int main(){ ios_base::sync_with_stdio(false);cin.tie(0); ll N,M; cin>>N>>M; vector<pair<ll,ll> > v[N]; vector<pair<pair<ll,ll>,ll> > A; for(ll i = 0;i < M;i++){ ll a,b,c; cin>>a>>b>>c; a -= 1; b -= 1; v[a].push_back(make_pair(b,c)); v[b].push_back(make_pair(a,c)); A.push_back(make_pair(make_pair(a,b),c)); } ll arr[N]; for(ll i = 0;i < N;i++){ arr[i] = 1; } for(ll i = 0;i < N;i++){ ll maximum = -1; for(auto u : v[i]){ if(maximum == -1 || u.second > maximum){ maximum = u.second; } } if(maximum != -1){ arr[i] = maximum; } } for(ll i = 0;i < M;i++){ if(arr[A[i].first.first] <= A[i].second){ arr[A[i].first.first] = A[i].second; }else if(arr[A[i].first.second] <= A[i].second){ arr[A[i].first.second] = A[i].second; } } for(ll i = 0;i < N;i++){ cout<<arr[i]<<" "; } cout<<'\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...