CSES - Datatähti 2022 alku - Results
Submission details
Task:Tietoverkko
Sender:tassu
Submission time:2021-10-05 18:57:51 +0300
Language:C++ (C++11)
Status:READY
Result:10
Feedback
groupverdictscore
#1ACCEPTED10
#20
#30
Test results
testverdicttimegroup
#1ACCEPTED0.01 s1, 2, 3details
#20.01 s2, 3details
#30.01 s3details

Code

#include <bits/stdc++.h>
#include <vector>

using namespace std;

long speed_total = 0;
vector<pair<int, long>> v[2000];

void search(int s, int e, long speed) {
    if (speed != 1000000000) {
        speed_total += speed;
    }

    for (auto u : v[s]) {
        if (u.first != e) {
            search(u.first, s, min(speed, u.second));
        }
    }
}

int main() {
    int l;
    cin >> l;

    int a, b;
    long x;

    for (int i = 1; i < l; i++) {
        cin >> a >> b >> x;
        v[a - 1].push_back({b - 1, x});
        v[b - 1].push_back({a - 1, x});
    }

    for (int j = 0; j < l; j++) {
        search(j, j, 1000000000);
    }

    cout << (speed_total / 2) << "\n";

    return 0;
}

Test details

Test 1

Group: 1, 2, 3

Verdict: ACCEPTED

input
100
1 2 74
1 3 100
2 4 50
3 5 40
...

correct output
88687

user output
88687

Test 2

Group: 2, 3

Verdict:

input
5000
1 2 613084013
1 3 832364259
2 4 411999902
3 5 989696303
...

correct output
1103702320243776

user output
(empty)

Test 3

Group: 3

Verdict:

input
200000
1 2 613084013
1 3 832364259
2 4 411999902
3 5 989696303
...

correct output
1080549209850010931

user output
(empty)