CSES - Datatähti 2022 alku - Results
Submission details
Task:Tietoverkko
Sender:EeliH
Submission time:2021-10-06 19:08:45 +0300
Language:C++11
Status:READY
Result:0
Feedback
groupverdictscore
#10
#20
#30
Test results
testverdicttimegroup
#10.01 s1, 2, 3details
#20.02 s2, 3details
#30.25 s3details

Code

#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

vector<struct A> c;
vector<int> a[200000];
    
struct A {
    int a;
    int b;
    int x;
};

bool a_comp(struct A q, struct A b)
{
    return q.x < b.x;
}

int maara(int q, int pois)
{
    int m = 1;
    for(int naapuri: a[q]) {
        if(naapuri != pois) {
            m += maara(naapuri, q);
        }
    }
    return m;
}

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

    for(int i = 0; i < n - 1; i++) {
        struct A b;
        cin >> b.a >> b.b >> b.x;
        c.push_back(b);
        a[b.a].push_back(b.b);
        a[b.b].push_back(b.a);
    }

    sort(c.begin(), c.end(), a_comp);

    uint64_t summa = 0;
    int h = 0;
    for(struct A i: c) {
        //cout << "A: " << i.a << " " << i.b << " " << i.x << endl;
        //cout << maara(i.a, i.b) << endl;
        /*for(int naapuri: a[i.a]) {

        }*/
        summa += (n - h - 1) * i.x;
        h++;
    }

    cout << summa << endl;
}

Test details

Test 1

Group: 1, 2, 3

Verdict:

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

correct output
88687

user output
162632

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
18446744050049295567

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)