| Task: | Tietoverkko |
| Sender: | EeliH |
| Submission time: | 2021-10-06 19:08:45 +0300 |
| Language: | C++ (C++11) |
| Status: | READY |
| Result: | 0 |
| group | verdict | score |
|---|---|---|
| #1 | WRONG ANSWER | 0 |
| #2 | WRONG ANSWER | 0 |
| #3 | WRONG ANSWER | 0 |
| test | verdict | time | group | |
|---|---|---|---|---|
| #1 | WRONG ANSWER | 0.01 s | 1, 2, 3 | details |
| #2 | WRONG ANSWER | 0.02 s | 2, 3 | details |
| #3 | RUNTIME ERROR | 0.25 s | 3 | details |
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: WRONG ANSWER
| 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: WRONG ANSWER
| 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: RUNTIME ERROR
| input |
|---|
| 200000 1 2 613084013 1 3 832364259 2 4 411999902 3 5 989696303 ... |
| correct output |
|---|
| 1080549209850010931 |
| user output |
|---|
| (empty) |
