Cod sursa(job #2444291)
| Utilizator | Data | 30 iulie 2019 22:52:43 | |
|---|---|---|---|
| Problema | Sortare topologica | Scor | 0 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.42 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream fin("sortaret.in");
ofstream fout("sortaret.out");
#define pb push_back
const int Nmax = 50000 + 5;
int n, m;
vector<int>v[Nmax];
void sortt(int nod)
{
fout << nod << ' ';
for(auto i : v[nod])
sortt(i);
}
int main()
{
fin >> n >> m;
for(int i = 1, a, b; i <= m; ++i)
{
fin >> a >> b;
v[a].pb(b);
}
sortt(1);
return 0;
}
