Cod sursa(job #3248504)
| Utilizator | Data | 12 octombrie 2024 09:19:56 | |
|---|---|---|---|
| Problema | Sortare topologica | Scor | 0 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.49 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream in("sortaret.in");
ofstream out("sortaret.out");
int nodes, edges;
int used[50005];
int main (){
int x, y;
in >> nodes >> edges;
for (int i=1; i<=edges; ++i){
in >> x >> y;
if (used[x] == 0){
used[x] = 1;
out << x << ' ';
}
if (used[y] == 0){
used[y] = 1;
out << y << ' ';
}
}
return 0;
}