Task: | Tietoverkko |
Sender: | motsgar |
Submission time: | 2021-10-13 18:01:03 +0300 |
Language: | C++ (C++17) |
Status: | READY |
Result: | 0 |
group | verdict | score |
---|---|---|
#1 | TIME LIMIT EXCEEDED | 0 |
#2 | TIME LIMIT EXCEEDED | 0 |
#3 | TIME LIMIT EXCEEDED | 0 |
test | verdict | time | group | |
---|---|---|---|---|
#1 | TIME LIMIT EXCEEDED | -- | 1, 2, 3 | details |
#2 | TIME LIMIT EXCEEDED | -- | 2, 3 | details |
#3 | TIME LIMIT EXCEEDED | -- | 3 | details |
Code
#include <bits/stdc++.h> using namespace std; typedef long long ll; pair<bool, int> getShortest(vector<vector<pair<int, int>>> computers, int comp1, int comp2, int prev) { for (unsigned int i = 0; i < computers[comp1].size(); i++) { if (computers[comp1][i].first == prev) { continue; } if (computers[comp1][i].first == comp2) { // next to return make_pair(true, computers[comp1][i].second); } pair<int, int> data = getShortest(computers, computers[comp1][i].first, comp2, comp1); if (data.first) { return make_pair(true, min(data.second, computers[comp1][i].second)); } } return make_pair(false, 0); } int main(int argc, char **argv) { ios_base::sync_with_stdio(false); cin.tie(NULL); ll total = 0; int amount; cin >> amount; vector<vector<pair<int, int>>> computers(amount); for (int i = 0; i < amount - 1; i++) { int a, b, x; cin >> a >> b >> x; computers[a - 1].push_back(pair<int, int>(b - 1, x)); computers[b - 1].push_back(pair<int, int>(a - 1, x)); } map<int, bool> went; for (int i = 0; i < amount; i++) { for (int j = 0; j < amount; j++) { if (i != j && !(went[i | (j << 9)] || went[j | (i << 9)])) { went[i | (j << 9)] = true; went[j | (i << 9)] = true; total += getShortest(computers, i, j, -1).second; } } } cout << total << "\n"; }
Test details
Test 1
Group: 1, 2, 3
Verdict: TIME LIMIT EXCEEDED
input |
---|
100 1 2 74 1 3 100 2 4 50 3 5 40 ... |
correct output |
---|
88687 |
user output |
---|
(empty) |
Test 2
Group: 2, 3
Verdict: TIME LIMIT EXCEEDED
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: TIME LIMIT EXCEEDED
input |
---|
200000 1 2 613084013 1 3 832364259 2 4 411999902 3 5 989696303 ... |
correct output |
---|
1080549209850010931 |
user output |
---|
(empty) |