Task: | Tietoverkko |
Sender: | T |
Submission time: | 2021-10-16 03:57:18 +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.14 s | 1, 2, 3 | details |
#2 | TIME LIMIT EXCEEDED | -- | 2, 3 | details |
#3 | RUNTIME ERROR | 0.01 s | 3 | details |
Compiler report
input/code.cpp: In function 'int main()': input/code.cpp:46:17: warning: 'u' may be used uninitialized in this function [-Wmaybe-uninitialized] if (u == destination) { ^~
Code
/** * Datatähti 2022 alku * Tietoverkko (Network) * @author TRS */ #include <bits/stdc++.h> using namespace std; //Constants #define infinity 0x3f3f3f3f #define linfinity 0x3f3f3f3f3f3f3f3f #define MOD 1000000007 const int MX = 200001; long long routeSpeed[MX], sourceNode[MX], nodeStatus[MX]; long long Answer; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n; cin>>n; long long network[n][n]; int a, b; long long x; for (int connection = 0; connection < n - 1; connection++) { cin>>a>>b>>x; network[a - 1][b - 1] = x; network[b - 1][a - 1] = x; } int u, v; for (int source = 0; source < n - 1; source++) { for (int destination = source + 1; destination < n; destination++) { for (int i = 0; i < n; i++) { routeSpeed[i] = linfinity; sourceNode[i] = -1; nodeStatus[i] = 0; } routeSpeed[source] = 0; for (int i = 0; i < n - 1; i++) { long long minimum = linfinity; for (v = 0; v < n; v++) { if (nodeStatus[v] == 0 && routeSpeed[v] <= minimum) { minimum = routeSpeed[v]; u = v; } } if (u == destination) { break; } nodeStatus[u] = 1; for (v = 0; v < n; v++) { if (nodeStatus[v] == 0 && network[u][v] != 0 && routeSpeed[u] + network[u][v] < routeSpeed[v]) { sourceNode[v] = u; routeSpeed[v] = routeSpeed[u] + network[u][v]; } } } long long answer = linfinity; long long to = destination, from = sourceNode[to]; while (from != -1) { answer = min(answer, network[from][to]); to = from; from = sourceNode[to]; } Answer += answer; } } cout<<Answer<<"\n"; return 0; }
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 |
---|
7679138092119364483 |
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: RUNTIME ERROR
input |
---|
200000 1 2 613084013 1 3 832364259 2 4 411999902 3 5 989696303 ... |
correct output |
---|
1080549209850010931 |
user output |
---|
(empty) |