Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- ifstream f(".in");
- ofstream g(".out");
- int a[3][100001],n,st[100001];
- void citire()
- {
- f>>n;
- int x,y,k=0;
- while(f>>x>>y)
- {
- k++;
- a[1][k]=y;
- a[2][k]=st[x];
- st[x]=k;
- }
- }
- void afis(int x)
- {
- g<<x<<" ";
- int unde=st[x];
- while(unde!=0)
- {
- g<<a[1][unde]<<" ";
- unde=a[2][unde];
- }
- g<<endl;
- }
- int main()
- { int i;
- citire();
- for(i=1; i<=n; i++)
- afis(i);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement