| Task: | Internet connection |
| Sender: | TuomoPera |
| Submission time: | 2020-09-19 16:55:35 +0300 |
| Language: | C++ (C++11) |
| Status: | READY |
| Result: | RUNTIME ERROR |
| test | verdict | time | |
|---|---|---|---|
| #1 | RUNTIME ERROR | 0.01 s | details |
| #2 | RUNTIME ERROR | 0.01 s | details |
| #3 | RUNTIME ERROR | 0.01 s | details |
| #4 | RUNTIME ERROR | 0.01 s | details |
| #5 | RUNTIME ERROR | 0.01 s | details |
| #6 | RUNTIME ERROR | 0.01 s | details |
| #7 | RUNTIME ERROR | 0.01 s | details |
| #8 | RUNTIME ERROR | 0.01 s | details |
| #9 | RUNTIME ERROR | 0.01 s | details |
| #10 | RUNTIME ERROR | 0.01 s | details |
| #11 | RUNTIME ERROR | 0.01 s | details |
| #12 | RUNTIME ERROR | 0.01 s | details |
| #13 | RUNTIME ERROR | 0.01 s | details |
| #14 | RUNTIME ERROR | 0.01 s | details |
| #15 | RUNTIME ERROR | 0.01 s | details |
| #16 | RUNTIME ERROR | 0.01 s | details |
| #17 | RUNTIME ERROR | 0.01 s | details |
| #18 | RUNTIME ERROR | 0.01 s | details |
| #19 | RUNTIME ERROR | 0.01 s | details |
| #20 | RUNTIME ERROR | 0.01 s | details |
| #21 | RUNTIME ERROR | 0.01 s | details |
| #22 | RUNTIME ERROR | 0.01 s | details |
Compiler report
input/code.cpp: In function 'int main()':
input/code.cpp:59:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i = 0; i < nodes.size() - 1; i++) {
~~^~~~~~~~~~~~~~~~~~
input/code.cpp:43:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
freopen("cases.txt", "r", stdin);
~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~Code
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define SIZE 1001
int g[SIZE][SIZE] = {0};
int c[SIZE][SIZE] = { 0 };
bool visited[SIZE] = { false };
int end_point = 0;
int result = 0;
bool solution_found = false;
vector<int> nodes;
int minimum = 9999999;
void traverse(int current) {
if (current == end_point) {
solution_found = true;
return;
}
for (int i = 1; i <= end_point; i++) {
if (g[current][i] > 0 && current != i && !visited[i] && !solution_found && (c[current][i] < (g[i][current] + g[current][i]))) {
nodes.push_back(i);
if (g[current][i] < minimum)
minimum = g[current][i];
//c[current][i] += 1;
//g[current][i] -= 1;
//g[i][current] += 1;
visited[i] = true;
traverse(i);
visited[i] = false;
if (!solution_found)
nodes.pop_back();
}
}
}
int main() {
freopen("cases.txt", "r", stdin);
int num;
cin >> end_point >> num;
for (int i = 0; i < num; i++) {
int a, b, c;
cin >> a >> b >> c;
g[a][b] = c;
}
visited[1] = true;
do {
solution_found = false;
nodes.push_back(1);
traverse(1);
if (solution_found) {
for (int i = 0; i < nodes.size() - 1; i++) {
g[nodes[i]][nodes[i + 1]] -= minimum;
g[nodes[i + 1]][nodes[i]] += minimum;
c[nodes[i]][nodes[i + 1]] += minimum;
}
result += minimum;
}
minimum = 999999999;
nodes.clear();
} while (solution_found);
cout << result << endl;
return 0;
}Test details
Test 1
Verdict: RUNTIME ERROR
| input |
|---|
| 10 20 5 6 19 4 5 47 3 5 7 4 9 62 ... |
| correct output |
|---|
| 73 |
| user output |
|---|
| (empty) |
Test 2
Verdict: RUNTIME ERROR
| input |
|---|
| 10 20 2 4 63 7 9 54 6 7 16 2 3 9 ... |
| correct output |
|---|
| 110 |
| user output |
|---|
| (empty) |
Test 3
Verdict: RUNTIME ERROR
| input |
|---|
| 10 20 5 6 90 2 3 46 7 8 80 6 7 60 ... |
| correct output |
|---|
| 29 |
| user output |
|---|
| (empty) |
Test 4
Verdict: RUNTIME ERROR
| input |
|---|
| 10 20 3 4 76 5 7 8 3 8 71 4 7 24 ... |
| correct output |
|---|
| 95 |
| user output |
|---|
| (empty) |
Test 5
Verdict: RUNTIME ERROR
| input |
|---|
| 10 20 1 8 22 6 7 40 4 5 20 8 10 77 ... |
| correct output |
|---|
| 156 |
| user output |
|---|
| (empty) |
Test 6
Verdict: RUNTIME ERROR
| input |
|---|
| 100 1000 63 85 864540192 22 91 974117435 64 66 953124912 85 88 6080960 ... |
| correct output |
|---|
| 4397669179 |
| user output |
|---|
| (empty) |
Test 7
Verdict: RUNTIME ERROR
| input |
|---|
| 100 1000 36 93 760720873 12 75 175717522 78 79 340128710 80 83 181753465 ... |
| correct output |
|---|
| 5298558023 |
| user output |
|---|
| (empty) |
Test 8
Verdict: RUNTIME ERROR
| input |
|---|
| 100 1000 20 60 909693891 55 91 570199535 21 41 118646902 37 82 824735480 ... |
| correct output |
|---|
| 5466229311 |
| user output |
|---|
| (empty) |
Test 9
Verdict: RUNTIME ERROR
| input |
|---|
| 100 1000 26 44 753330451 62 67 821574279 70 95 219303983 7 44 980013084 ... |
| correct output |
|---|
| 4893925638 |
| user output |
|---|
| (empty) |
Test 10
Verdict: RUNTIME ERROR
| input |
|---|
| 100 1000 15 89 501388091 50 71 396801720 15 92 324349822 29 85 184420157 ... |
| correct output |
|---|
| 6956499595 |
| user output |
|---|
| (empty) |
Test 11
Verdict: RUNTIME ERROR
| input |
|---|
| 2 1 1 2 1 |
| correct output |
|---|
| 1 |
| user output |
|---|
| (empty) |
Test 12
Verdict: RUNTIME ERROR
| input |
|---|
| 2 1 2 1 1 |
| correct output |
|---|
| 0 |
| user output |
|---|
| (empty) |
Test 13
Verdict: RUNTIME ERROR
| input |
|---|
| 2 2 1 2 1 2 1 1 |
| correct output |
|---|
| 1 |
| user output |
|---|
| (empty) |
Test 14
Verdict: RUNTIME ERROR
| input |
|---|
| 100 1000 1 2 539540023 2 3 244306651 3 4 253259012 3 5 630461598 ... |
| correct output |
|---|
| 0 |
| user output |
|---|
| (empty) |
Test 15
Verdict: RUNTIME ERROR
| input |
|---|
| 4 5 1 2 2 1 3 5 2 4 3 3 2 2 ... |
| correct output |
|---|
| 4 |
| user output |
|---|
| (empty) |
Test 16
Verdict: RUNTIME ERROR
| input |
|---|
| 2 0 |
| correct output |
|---|
| 0 |
| user output |
|---|
| (empty) |
Test 17
Verdict: RUNTIME ERROR
| input |
|---|
| 100 0 |
| correct output |
|---|
| 0 |
| user output |
|---|
| (empty) |
Test 18
Verdict: RUNTIME ERROR
| input |
|---|
| 100 196 1 2 1000000000 2 100 1000000000 1 3 1000000000 3 100 1000000000 ... |
| correct output |
|---|
| 98000000000 |
| user output |
|---|
| (empty) |
Test 19
Verdict: RUNTIME ERROR
| input |
|---|
| 100 99 1 2 1000000000 2 3 1000000000 3 4 1000000000 4 5 1000000000 ... |
| correct output |
|---|
| 1000000000 |
| user output |
|---|
| (empty) |
Test 20
Verdict: RUNTIME ERROR
| input |
|---|
| 2 2 2 1 1 1 2 1 |
| correct output |
|---|
| 1 |
| user output |
|---|
| (empty) |
Test 21
Verdict: RUNTIME ERROR
| input |
|---|
| 4 6 1 2 1000000000 1 3 1000000000 2 3 1 2 4 1000000000 ... |
| correct output |
|---|
| 2000000000 |
| user output |
|---|
| (empty) |
Test 22
Verdict: RUNTIME ERROR
| input |
|---|
| 4 6 1 2 1000000000 1 3 1000000000 2 4 1000000000 2 3 1 ... |
| correct output |
|---|
| 2000000000 |
| user output |
|---|
| (empty) |
