Untitled
user_0483151
plain_text
a month ago
985 B
2
Indexable
// y.ha #include <bits/stdc++.h> #define cook '\n' #define maxn 100001 #define Task "A" using namespace std; int n,u,tr[maxn],need; vector<int> nxt[maxn]; void inp() { cin >> n ; int x,y ; while ( cin >> x >> y ) { nxt[x].push_back(y) ; nxt[y].push_back(x) ; } } void write(int u,int v) { vector<int> way ; while ( u != v ) { way.push_back(tr[u]) ; u = tr[u] ; } for ( int x : way ) cout << x << " " ; exit(0) ; } bool dfs(int u,bool ok) { if ( u == need ) return true ; for ( int v : nxt[u] ) { if ( tr[v] || ( v == need && !ok )) continue ; tr[v] = u ; dfs(v,1) ; } } int main() { ios_base::sync_with_stdio(0) ; cin.tie(nullptr) ; if(fopen(Task".INP","r")) { freopen(Task".INP","r",stdin); freopen(Task".OUT","w",stdout); } inp() ; need = 2; cout << dfs(3,0) ; return(0) ; }
Editor is loading...
Leave a Comment