Pagini recente » Cod sursa (job #1523499) | Cod sursa (job #2665775) | Cod sursa (job #3200753) | Cod sursa (job #999783) | Cod sursa (job #804462)
Cod sursa(job #804462)
#include <fstream>
#include <vector>
using namespace std;
//ifstream fin("input.txt");
//ofstream fout("output.txt");
ifstream fin("sortaret.in");
ofstream fout("sortaret.out");
int n, m;
int pus[50001];
vector <int> V[50001];
void citire()
{
int x, y;
fin >> n >> m;
while(fin >> x >> y)
{
V[x].push_back(y);
//V[y].push_back(x);
}
}
void DF(int k)
{
pus[k] = 1;
fout << k << " ";
for(int i = 0; i < V[k].size(); i++)
if(!pus[V[k][i]]) DF(V[k][i]);
}
int main()
{
citire();
DF(1);
fin.close();
fout.close();
fin.close();
}