Pagini recente » Cod sursa (job #873790) | Cod sursa (job #2240445) | Cod sursa (job #325048) | Cod sursa (job #2544331) | Cod sursa (job #2952647)
#include <bits/stdc++.h>
using namespace std;
ifstream fin("sortaret.in");
ofstream fout("sortaret.out");
int n, m, x, y;
vector<int> a[50001];
void sorttop(int i) {
sort(a[i].begin(), a[i].end());
for (int x : a[i]) {
fout << x << " ";
}
for (int x : a[i]) {
sorttop(x);
}
}
int main() {
fin >> n >> m;
for (int i = 0; i < m; i++) {
fin >> x >> y;
a[x].push_back(y);
}
fout << "1 ";
sorttop(1);
}