42972023-03-22 13:57:15horvathabelTestnevelés óracpp17Wrong answer 1/50250ms121752 KiB
#include <bits/stdc++.h>
using namespace std;
vector<int> g[2000001];
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;
	cin>>n;
	int m;
	cin>>m;
	pair<int ,int> mx={0,0};
	vector<int>db(n+1);
	for (int i=0; i<m;i++){
		int x,y;
		cin>>x>>y; 
		db[x]++;
		if (db[x]>mx.first){
			mx={db[x],x};
		}
		g[x].push_back(y);
		g[y].push_back(x);
	}
	dfs(mx.second);
	cout<<1<<endl;
	reverse(topo.begin(), topo.end());
	for (int i:topo) cout<<i<<" "; 
}

SubtaskSumTestVerdictTimeMemory
base1/50
1Wrong answer0/037ms95536 KiB
2Wrong answer0/046ms95704 KiB
3Wrong answer0/0238ms111848 KiB
4Wrong answer0/245ms96128 KiB
5Wrong answer0/345ms96488 KiB
6Wrong answer0/345ms96372 KiB
7Wrong answer0/345ms96500 KiB
8Wrong answer0/145ms96620 KiB
9Wrong answer0/345ms96856 KiB
10Wrong answer0/339ms97164 KiB
11Wrong answer0/346ms97168 KiB
12Wrong answer0/146ms97084 KiB
13Wrong answer0/246ms97344 KiB
14Wrong answer0/346ms97240 KiB
15Wrong answer0/1216ms109108 KiB
16Wrong answer0/3180ms108348 KiB
17Wrong answer0/537ms98788 KiB
18Wrong answer0/1250ms114844 KiB
19Partially correct1/2208ms109368 KiB
20Wrong answer0/3218ms121752 KiB
21Wrong answer0/4203ms117960 KiB
22Wrong answer0/4204ms118244 KiB