Pagini recente » Borderou de evaluare (job #1618360) | Cod sursa (job #546059) | Cod sursa (job #1316275) | Cod sursa (job #2594022) | Cod sursa (job #1412275)
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define fs first
#define sc second
#define pob pop_back
#define pub push_back
#define eps 1E-7
#define sz(a) a.size()
#define count_one __builtin_popcount;
#define count_onell __builtin_popcountll;
#define fastIO ios_base::sync_with_stdio(false)
#define PI (acos(-1.0))
#define linf (1LL<<62)//>4e18
#define inf (0x7f7f7f7f)//>2e9
#define MAXN 50010
int n, m;
bitset<MAXN> viz;
vector<int> vec[MAXN];
stack<int> stk;
void dfs(int nod) {
viz[nod] = true;
for(auto it : vec[nod])
if(!viz[it])
dfs(it);
stk.push(nod);
}
void read() {
#ifndef ONLINE_JUDGE
assert(freopen("sortaret.in", "r", stdin));
assert(freopen("sortaret.out", "w", stdout));
#endif
scanf("%d%d", &n, &m);
int x, y;
for(int i = 0; i < m; ++i) {
scanf("%d%d", &x, &y);
vec[x].pub(y);
}
for(int i = 1; i <= n; ++i)
if(!viz[i])
dfs(i);
for(; !stk.empty(); stk.pop())
printf("%d ", stk.top());
}
int main() {
read();
return 0;
}