Task: | Internet connection |
Sender: | TuomoPera |
Submission time: | 2020-09-19 14:57:53 +0300 |
Language: | C++ (C++11) |
Status: | READY |
Result: | WRONG ANSWER |
test | verdict | time | |
---|---|---|---|
#1 | WRONG ANSWER | 0.01 s | details |
#2 | ACCEPTED | 0.01 s | details |
#3 | ACCEPTED | 0.01 s | details |
#4 | WRONG ANSWER | 0.01 s | details |
#5 | ACCEPTED | 0.01 s | details |
#6 | TIME LIMIT EXCEEDED | -- | details |
#7 | TIME LIMIT EXCEEDED | -- | details |
#8 | TIME LIMIT EXCEEDED | -- | details |
#9 | TIME LIMIT EXCEEDED | -- | details |
#10 | TIME LIMIT EXCEEDED | -- | details |
#11 | ACCEPTED | 0.01 s | details |
#12 | ACCEPTED | 0.01 s | details |
#13 | ACCEPTED | 0.01 s | details |
#14 | TIME LIMIT EXCEEDED | -- | details |
#15 | ACCEPTED | 0.01 s | details |
#16 | ACCEPTED | 0.01 s | details |
#17 | ACCEPTED | 0.01 s | details |
#18 | TIME LIMIT EXCEEDED | -- | details |
#19 | TIME LIMIT EXCEEDED | -- | details |
#20 | ACCEPTED | 0.01 s | details |
#21 | TIME LIMIT EXCEEDED | -- | details |
#22 | TIME LIMIT EXCEEDED | -- | details |
Code
#include <iostream> #include <string> using namespace std; int g[1000][1000] = {0}; bool visited[1000] = { false }; int end_point = 0; int result = 0; bool solution_found = false; void traverse(int current) { if (current == end_point) { result += 1; solution_found = true; return; } for (int i = 1; i <= end_point; i++) { if (g[current][i] > 0 && current != i && !visited[i] && !solution_found) { g[current][i] -= 1; g[i][current] += 1; visited[i] = true; traverse(i); visited[i] = false; } } /* if (g[current][1] > 0 && current != 1 && !visited[1] && !solution_found) { g[current][1] -= 1; g[1][current] += 1; visited[1] = true; traverse(1); visited[1] = false; } if (g[current][2] > 0 && current != 2 && !visited[2] && !solution_found) { g[current][2] -= 1; g[2][current] += 1; visited[2] = true; traverse(2); visited[2] = false; } if (g[current][3] > 0 && current != 3 && !visited[3] && !solution_found) { g[current][3] -= 1; g[3][current] += 1; visited[3] = true; traverse(3); visited[3] = false; } if (g[current][4] > 0 && current != 4 && !visited[4] && !solution_found) { g[current][4] -= 1; g[4][current] += 1; visited[4] = true; traverse(4); visited[4] = false; } */ } 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; traverse(1); } while (solution_found); cout << result << endl; return 0; }
Test details
Test 1
Verdict: WRONG ANSWER
input |
---|
10 20 5 6 19 4 5 47 3 5 7 4 9 62 ... |
correct output |
---|
73 |
user output |
---|
92 |
Test 2
Verdict: ACCEPTED
input |
---|
10 20 2 4 63 7 9 54 6 7 16 2 3 9 ... |
correct output |
---|
110 |
user output |
---|
110 |
Test 3
Verdict: ACCEPTED
input |
---|
10 20 5 6 90 2 3 46 7 8 80 6 7 60 ... |
correct output |
---|
29 |
user output |
---|
29 |
Test 4
Verdict: WRONG ANSWER
input |
---|
10 20 3 4 76 5 7 8 3 8 71 4 7 24 ... |
correct output |
---|
95 |
user output |
---|
136 |
Test 5
Verdict: ACCEPTED
input |
---|
10 20 1 8 22 6 7 40 4 5 20 8 10 77 ... |
correct output |
---|
156 |
user output |
---|
156 |
Test 6
Verdict: TIME LIMIT EXCEEDED
input |
---|
100 1000 63 85 864540192 22 91 974117435 64 66 953124912 85 88 6080960 ... |
correct output |
---|
4397669179 |
user output |
---|
(empty) |
Test 7
Verdict: TIME LIMIT EXCEEDED
input |
---|
100 1000 36 93 760720873 12 75 175717522 78 79 340128710 80 83 181753465 ... |
correct output |
---|
5298558023 |
user output |
---|
(empty) |
Test 8
Verdict: TIME LIMIT EXCEEDED
input |
---|
100 1000 20 60 909693891 55 91 570199535 21 41 118646902 37 82 824735480 ... |
correct output |
---|
5466229311 |
user output |
---|
(empty) |
Test 9
Verdict: TIME LIMIT EXCEEDED
input |
---|
100 1000 26 44 753330451 62 67 821574279 70 95 219303983 7 44 980013084 ... |
correct output |
---|
4893925638 |
user output |
---|
(empty) |
Test 10
Verdict: TIME LIMIT EXCEEDED
input |
---|
100 1000 15 89 501388091 50 71 396801720 15 92 324349822 29 85 184420157 ... |
correct output |
---|
6956499595 |
user output |
---|
(empty) |
Test 11
Verdict: ACCEPTED
input |
---|
2 1 1 2 1 |
correct output |
---|
1 |
user output |
---|
1 |
Test 12
Verdict: ACCEPTED
input |
---|
2 1 2 1 1 |
correct output |
---|
0 |
user output |
---|
0 |
Test 13
Verdict: ACCEPTED
input |
---|
2 2 1 2 1 2 1 1 |
correct output |
---|
1 |
user output |
---|
1 |
Test 14
Verdict: TIME LIMIT EXCEEDED
input |
---|
100 1000 1 2 539540023 2 3 244306651 3 4 253259012 3 5 630461598 ... |
correct output |
---|
0 |
user output |
---|
(empty) |
Test 15
Verdict: ACCEPTED
input |
---|
4 5 1 2 2 1 3 5 2 4 3 3 2 2 ... |
correct output |
---|
4 |
user output |
---|
4 |
Test 16
Verdict: ACCEPTED
input |
---|
2 0 |
correct output |
---|
0 |
user output |
---|
0 |
Test 17
Verdict: ACCEPTED
input |
---|
100 0 |
correct output |
---|
0 |
user output |
---|
0 |
Test 18
Verdict: TIME LIMIT EXCEEDED
input |
---|
100 196 1 2 1000000000 2 100 1000000000 1 3 1000000000 3 100 1000000000 ... |
correct output |
---|
98000000000 |
user output |
---|
(empty) |
Test 19
Verdict: TIME LIMIT EXCEEDED
input |
---|
100 99 1 2 1000000000 2 3 1000000000 3 4 1000000000 4 5 1000000000 ... |
correct output |
---|
1000000000 |
user output |
---|
(empty) |
Test 20
Verdict: ACCEPTED
input |
---|
2 2 2 1 1 1 2 1 |
correct output |
---|
1 |
user output |
---|
1 |
Test 21
Verdict: TIME LIMIT EXCEEDED
input |
---|
4 6 1 2 1000000000 1 3 1000000000 2 3 1 2 4 1000000000 ... |
correct output |
---|
2000000000 |
user output |
---|
(empty) |
Test 22
Verdict: TIME LIMIT EXCEEDED
input |
---|
4 6 1 2 1000000000 1 3 1000000000 2 4 1000000000 2 3 1 ... |
correct output |
---|
2000000000 |
user output |
---|
(empty) |