Pagini recente » Cod sursa (job #3280877) | Cod sursa (job #1418193) | Cod sursa (job #2988379) | Cod sursa (job #26517) | Cod sursa (job #1334185)
#include<fstream>
#include<vector>
using namespace std;
ifstream f("sortaret.in");
ofstream o("sortaret.out");
vector <int> a[50100];
int n,m,d[50200];
void df(int x){
d[x]=1;
for(int i=0;i<a[x].size();i++)
if(d[a[x][i]]==0)df(a[x][i]);
o<<x<<" ";
}
int main(){
f>>n>>m;
int x,y;
for(int i=1;i<=m;i++)f>>x>>y,a[y].push_back(x);
for(int i=1;i<=n;i++)if(d[i]==0)df(i);
}