Task: | Tietoverkko |
Sender: | Salama |
Submission time: | 2021-10-12 22:11:23 +0300 |
Language: | C++ (C++17) |
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.18 s | 2, 3 | details |
#3 | TIME LIMIT EXCEEDED | -- | 3 | details |
Code
#include <bits/stdc++.h>using namespace std;unsigned long long tc = 0;map<unsigned, map<unsigned long long, unsigned long long>> v;map<unsigned, unsigned long long> h;int n;unsigned long long haku(unsigned long long s, unsigned long long e, int d, unsigned long long maxc) {for (auto u : v[s]) {if (u.first == e) continue;h[u.first] = haku(u.first, s, d, min(maxc, u.second));}unsigned long long sum = 0;map<unsigned, unsigned long long>::iterator i = h.begin();if(h.size() > 0)for(;i != h.end(); i++) {sum += min(maxc, i->second);}else sum = maxc;tc += sum;//cout << s+1 << ": " << sum << "\n";return maxc;//cout << c[s] << "\n";}int main () {ios_base::sync_with_stdio(0);cin.tie(0);unsigned long long a, b;unsigned long long x;cin >> n;for(int i = 0; i < n-1; i++) {cin >> a >> b >> x;v[a-1][b-1] = x;v[b-1][a-1] = x;}haku(0, -1, n, -1);cout << tc-1 << "\n";}
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 |
---|
83683 |
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 |
---|
1076150712403605 |
Test 3
Group: 3
Verdict: TIME LIMIT EXCEEDED
input |
---|
200000 1 2 613084013 1 3 832364259 2 4 411999902 3 5 989696303 ... |
correct output |
---|
1080549209850010931 |
user output |
---|
(empty) |