Cod sursa(job #2230808)
| Utilizator | Data | 11 august 2018 16:19:01 | |
|---|---|---|---|
| Problema | Sortare topologica | Scor | 0 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.55 kb |
#include <iostream>
#include <queue>
#include <fstream>
#include <cstring>
using namespace std;
ifstream f ("sortaret.in");
ofstream g ("sortaret.out");
queue <int> q;
bool verif[100000];
int main()
{
int n,m;
f>>n>>m;
for(int i=1;i<=m;i++)
{
int x,y;
f>>x>>y;
if(!verif[x])
q.push(x);
if(!verif[y])
q.push(y);
verif[x] = 1;
verif[y] = 1;
}
for(int i=1;i<=n;i++)
{
g<<q.front()<<' ';
q.pop();
}
return 0;
}
