| Task: | Distinct Routes |
| Sender: | aalto26gm_028 |
| Submission time: | 2026-10-19 17:51:53 +0300 |
| Language: | C++ (C++20) |
| Status: | READY |
| Result: | WRONG ANSWER |
| test | verdict | time | |
|---|---|---|---|
| #1 | WRONG ANSWER | 0.00 s | details |
| #2 | ACCEPTED | 0.00 s | details |
| #3 | WRONG ANSWER | 0.01 s | details |
| #4 | WRONG ANSWER | 0.01 s | details |
| #5 | ACCEPTED | 0.00 s | details |
| #6 | RUNTIME ERROR | 0.01 s | details |
| #7 | RUNTIME ERROR | 0.01 s | details |
| #8 | WRONG ANSWER | 0.01 s | details |
| #9 | WRONG ANSWER | 0.00 s | details |
| #10 | WRONG ANSWER | 0.00 s | details |
| #11 | WRONG ANSWER | 0.00 s | details |
| #12 | WRONG ANSWER | 0.00 s | details |
| #13 | WRONG ANSWER | 0.00 s | details |
| #14 | WRONG ANSWER | 0.00 s | details |
| #15 | WRONG ANSWER | 0.01 s | details |
Compiler report
input/code.cpp: In function 'int main()':
input/code.cpp:67:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
67 | for (int i = 0; i < path.size()-1; i++) {
| ~~^~~~~~~~~~~~~~~
input/code.cpp:92:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
92 | for (int i = 0; i < path.size() - 1; i++) {
| ~~^~~~~~~~~~~~~~~~~
input/code.cpp:101:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
101 | for (int i = 0; i < u.size(); i++) {
| ~~^~~~~~~~~~Code
#include <bits/stdc++.h>
using namespace std;
#define ll long long
void one_dfs(int current, int end, vector<bool>& visited, vector<map<int, bool>>& g, vector<int>& path, bool& completed) {
// cout << current << " " << end << endl;
if (current == end) {
completed = true;
path.push_back(current);
return;
}
if (visited[current]) return;
visited[current] = true;
path.push_back(current);
for (auto &[v, possible] : g[current]) {
if (!possible) continue;
one_dfs(v, end, visited, g, path, completed);
if (completed) return;
}
path.pop_back();
}
int main() {
int n, m;
cin >> n >> m;
vector<map<int, bool>> g(n);
vector<pair<int, int>> edges;
for (int i = 0; i < m; i++) {
int u, v;
cin >> u >> v;
u--;
v--;
g[u][v] = true;
edges.push_back({u, v});
}
bool completed;
vector<bool> visited(n);
vector<int> path;
vector<vector<int>> valids;
int k =0;
while (true) {
path.erase(path.begin(), path.end());
for (int i = 0; i < n; i++) visited[i] = false;
completed = false;
one_dfs(0, n-1, visited, g, path, completed);
// cout << path.size() << endl;
if (completed) {
valids.push_back(vector<int>());
k++;
for (int i = 0; i < path.size()-1; i++) {
g[path[i]][path[i+1]] = false;
g[path[i + 1]][path[i]] = true;
valids[valids.size()-1].push_back(path[i]);
}
valids[valids.size()-1].push_back(path[path.size() - 1]);
} else {
break;
}
}
vector<map<int, bool>> g_final(n);
for (auto &[u, v] : edges) {
if (!g[u][v]) {
g_final[u][v] = true;
}
}
for (int j = 0; j < k; j++) {
path.erase(path.begin(), path.end());
for (int i = 0; i < n; i++) visited[i] = false;
completed = false;
one_dfs(0, n - 1, visited, g_final, path, completed);
for (int i = 0; i < path.size() - 1; i++) {
g_final[path[i]][path[i + 1]] = false;
}
valids.push_back(path);
}
cout << valids.size() << endl;
for (auto &u : valids) {
cout << u.size() << endl;
for (int i = 0; i < u.size(); i++) {
if (i > 0) cout << " ";
cout << u[i]+1;
}
cout << endl;
}
}Test details
Test 1
Verdict: WRONG ANSWER
| input |
|---|
| 2 1 1 2 |
| correct output |
|---|
| 1 2 1 2 |
| user output |
|---|
| 2 2 1 2 2 1 2 |
Test 2
Verdict: ACCEPTED
| input |
|---|
| 4 2 1 2 3 4 |
| correct output |
|---|
| 0 |
| user output |
|---|
| 0 |
Test 3
Verdict: WRONG ANSWER
| input |
|---|
| 500 996 1 2 2 500 1 3 3 500 ... |
| correct output |
|---|
| 498 3 1 2 500 3 1 3 500 ... |
| user output |
|---|
| 996 3 1 2 500 3 1 3 500 ... |
Test 4
Verdict: WRONG ANSWER
| input |
|---|
| 500 499 1 2 2 3 3 4 4 5 ... |
| correct output |
|---|
| 1 500 1 2 3 4 5 6 7 8 9 10 11 12 13 ... |
| user output |
|---|
| 2 500 1 2 3 4 5 6 7 8 9 10 11 12 13 ... |
Test 5
Verdict: ACCEPTED
| input |
|---|
| 2 1 2 1 |
| correct output |
|---|
| 0 |
| user output |
|---|
| 0 |
Test 6
Verdict: RUNTIME ERROR
| input |
|---|
| 40 1000 25 22 15 24 7 33 16 32 ... |
| correct output |
|---|
| 21 44 1 35 39 34 29 32 22 38 20 30 1... |
| user output |
|---|
| (empty) |
Test 7
Verdict: RUNTIME ERROR
| input |
|---|
| 75 1000 72 6 46 66 63 45 70 46 ... |
| correct output |
|---|
| 12 30 1 29 24 9 18 63 45 31 66 72 6 ... |
| user output |
|---|
| (empty) |
Test 8
Verdict: WRONG ANSWER
| input |
|---|
| 100 1000 75 97 7 62 88 25 36 44 ... |
| correct output |
|---|
| 9 51 1 35 15 86 79 34 43 94 83 75 9... |
| user output |
|---|
| 18 91 1 6 34 8 21 23 2 16 35 15 7 4 ... |
Test 9
Verdict: WRONG ANSWER
| input |
|---|
| 3 2 1 2 2 3 |
| correct output |
|---|
| 1 3 1 2 3 |
| user output |
|---|
| 2 3 1 2 3 3 1 2 3 |
Test 10
Verdict: WRONG ANSWER
| input |
|---|
| 11 12 1 2 2 3 3 4 4 5 ... |
| correct output |
|---|
| 2 6 1 2 3 4 5 11 7 1 6 7 8 9 10 11 |
| user output |
|---|
| 4 6 1 2 3 4 5 11 7 1 6 7 8 9 10 11 ... |
Test 11
Verdict: WRONG ANSWER
| input |
|---|
| 8 9 1 2 2 3 3 8 1 4 ... |
| correct output |
|---|
| 2 5 1 2 6 7 8 5 1 4 5 3 8 |
| user output |
|---|
| 4 4 1 2 3 8 8 1 4 5 3 2 6 7 8 ... |
Test 12
Verdict: WRONG ANSWER
| input |
|---|
| 8 9 1 2 1 3 2 3 3 4 ... |
| correct output |
|---|
| 1 8 1 2 3 4 5 6 7 8 |
| user output |
|---|
| 2 8 1 2 3 4 5 6 7 8 8 1 2 3 4 5 6 7 8 |
Test 13
Verdict: WRONG ANSWER
| input |
|---|
| 7 9 1 2 1 3 2 7 3 4 ... |
| correct output |
|---|
| 3 3 1 2 7 4 1 3 5 7 ... |
| user output |
|---|
| 6 3 1 2 7 4 1 3 4 7 ... |
Test 14
Verdict: WRONG ANSWER
| input |
|---|
| 7 15 3 6 5 2 5 4 3 5 ... |
| correct output |
|---|
| 2 5 1 2 3 6 7 4 1 4 5 7 |
| user output |
|---|
| 4 5 1 2 3 5 7 6 1 4 5 3 6 7 ... |
Test 15
Verdict: WRONG ANSWER
| input |
|---|
| 500 986 244 252 224 22 81 484 273 432 ... |
| correct output |
|---|
| 116 5 1 129 142 473 500 5 1 63 158 171 500 ... |
| user output |
|---|
| 232 5 1 3 305 338 500 6 1 10 152 416 438 500 ... |
