Pagini recente » Cod sursa (job #2905568) | Cod sursa (job #1281770) | Cod sursa (job #1870957) | Cod sursa (job #800386) | Cod sursa (job #3127039)
{\rtf1\mac\ansicpg10000\cocoartf2709
\cocoatextscaling0\cocoaplatform0{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
{\colortbl;\red255\green255\blue255;}
{\*\expandedcolortbl;;}
\paperw11900\paperh16840\margl1440\margr1440\vieww11520\viewh8400\viewkind0
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural\partightenfactor0
\f0\fs24 \cf0 /******************************************************************************\
\
Online C++ Compiler.\
Code, Compile, Run and Debug C++ program online.\
Write your code in this editor and press "Run" button to compile and execute it.\
\
*******************************************************************************/\
\
#include <fstream>\
#include <vector>\
\
using namespace std;\
ifstream fin("sortaret.in");\
ofstream fout("sortaret.out");\
vector<int>g[100001];\
int n, viz[100001],m;\
int sorttop[100001],cnt;\
\
void dfs(int x) \{\
viz[x] = 1;\
for(auto y : g[x]) \{\
if(!viz[y])\
dfs(y);\
\}\
sorttop[++cnt]= x;\
\}\
\
int main()\
\{\
fin >> n>>m;\
for(int i = 1,x,y; i <= m; ++i) \{\
fin >> x >> y;\
g[x].push_back(y);\
\}\
dfs(1);\
for(int i = cnt; i>=1; --i)\
fout << sorttop[i] << " ";\
\
return 0;\
\}\
}