43282023-03-24 16:03:23horvathabelTestnevelés óracpp17Wrong answer 5/50200ms38128 KiB
#include <bits/stdc++.h>
using namespace std;
vector<int> g[200001];
vector<int> topo;
bool seen[2000001];
void dfs(int x){
	if (!seen[x]){
		seen[x]=true; 
		for (int edge:g[x]){
			dfs(edge);
		}
		topo.push_back(x);

	}
}

int main() {
	int n,m;
	cin>>n>>m;
	for (int i=0; i<m;i++){
		int x,y;
		cin>>x>>y;
		g[x].push_back(y);
	}
	for (int i=1; i<=n;i++){
		if (!seen[i]){
			dfs(i);
		}
	}
	reverse(topo.begin(), topo.end());
	cout<<1<<endl; 
	for (int x:topo) cout<<x<<" "; 
}
SubtaskSumTestVerdictTimeMemory
base5/50
1Accepted0/07ms11304 KiB
2Wrong answer0/07ms11856 KiB
3Wrong answer0/0172ms17888 KiB
4Wrong answer0/27ms11676 KiB
5Wrong answer0/36ms11672 KiB
6Wrong answer0/36ms11944 KiB
7Wrong answer0/34ms12232 KiB
8Wrong answer0/16ms12052 KiB
9Wrong answer0/36ms12452 KiB
10Wrong answer0/37ms12428 KiB
11Wrong answer0/37ms12500 KiB
12Wrong answer0/17ms12732 KiB
13Accepted2/28ms12964 KiB
14Wrong answer0/37ms12888 KiB
15Accepted1/1160ms17828 KiB
16Wrong answer0/3131ms22736 KiB
17Wrong answer0/532ms15560 KiB
18Wrong answer0/1200ms23164 KiB
19Accepted2/2163ms18280 KiB
20Wrong answer0/3174ms31876 KiB
21Wrong answer0/4179ms38128 KiB
22Wrong answer0/4177ms34324 KiB