Cod sursa(job #392583)
| Utilizator | Data | 7 februarie 2010 19:45:31 | |
|---|---|---|---|
| Problema | Sortare topologica | Scor | 0 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.33 kb |
#include <fstream>
using namespace std;
int v[50000],x,y;
int main()
{
int n,m,i;
ifstream f("sortaret.in");
ofstream o("sortaret.out");
f>>n>>m;
v[0]=-1;
while (m--)
{
f>>x>>y;
if (v[y]<x)v[y]=x;
}
int a=0;
while (a!=n)
for (i=1;i<=n;i++)
if (v[v[i]]==-1) {o<<i<<" ";a++;v[i]=-1;}
return 0;
}
