Nu exista pagina, dar poti sa o creezi ...
Cod sursa(job #1574661)
| Utilizator | Data | 20 ianuarie 2016 19:11:15 | |
|---|---|---|---|
| Problema | Sortare topologica | Scor | 0 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.69 kb |
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <string>
using namespace std;
unordered_map <string, bool> mp;
vector <int> v;
int n, m;
string x("x");
ifstream fin("sortaret.in");
ofstream fout("sortaret.out");
bool cmp(int a, int b)
{
return mp[to_string(a)+x+to_string(b)] == 1;
}
int main()
{
fin >> n >> m;
for(int i = 0; i < n; i++)
{
v.push_back(i+1);
}
int a, b;
for(int i = 0; i < m; i++)
{
fin >> a >> b;
mp[to_string(a)+x+to_string(b)] = 1;
}
sort(v.begin(), v.end(), cmp);
for(auto i : v)
{
fout << i << ' ';
}
}
