# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
731090 | Ivo_12 | Torrent (COI16_torrent) | C++17 | 205 ms | 18376 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
int n, a, b, x, y;
vector < int > connections[300010];
vector < int > trail;
bool find_trail( int prev, int cur ) {
if(cur == b) {
trail.push_back(cur);
return 1;
}
for(int i = 0; i < connections[cur].size(); i++) {
if(connections[cur][i] != prev) {
if(find_trail(cur, connections[cur][i])) {
trail.push_back(cur);
return 1;
}
}
}
return 0;
}
int main( void ) {
cin >> n >> a >> b;
for(int i = 0; i < n-1; i++) {
cin >> x >> y;
connections[x].push_back(y);
connections[y].push_back(x);
}
find_trail(-1, a);
// for(int i = 0; i < trail.size(); i++) {
// cout << trail[i] << " ";
// }
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |