Submission #1349474

#TimeUsernameProblemLanguageResultExecution timeMemory
1349474mozkunLost Array (NOI19_lostarray)C++20
11 / 100
3 ms1860 KiB
#include<bits/stdc++.h>
using namespace std;
#define ll long long

int main(){
    cin.tie(nullptr)->sync_with_stdio(false);

    int n, m;
    cin >> n >> m;

    vector<tuple<ll,int,int>> edges;

    for(int i = 0; i < m; i++){
        int a, b;
        ll c;
        cin >> a >> b >> c;
        edges.emplace_back(c, a, b);
    }

    sort(edges.begin(), edges.end());

    vector<ll> x(n+1, (ll)1e9);

    for(auto [c, a, b] : edges){
        if(x[a] == c || x[b] == c) continue;

        if(x[a] > x[b]) x[a] = c;
        else x[b] = c;
    }

    for(int i = 1; i <= n; i++){
        cout << x[i] << " ";
    }
    cout << "\n";

    return 0;
}
#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...