101352024-03-27 23:53:13111Turista járatokcpp17Wrong answer 0/100172ms75564 KiB
#include <bits/stdc++.h>
using namespace std;

#define int long long

signed main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int N,M,K;
	cin>>N>>M>>K;
	vector<vector<pair<int,int>>>g(N+1);
	for(int i=0;i<M;i++){
		int a,b;
		cin>>a>>b;
		g[a].emplace_back(b,i<K);
		g[b].emplace_back(a,i<K);
	}
	vector<int>v(N+1),w(N+1),u(N+1);
	auto dfs=[&](auto self,int i)->void{
		w[i]=i;
		for(auto[j,b]:g[i]){
			if(v[j]){
				if(v[j]>=v[i]-1){
					continue;
				}
				if(v[j]<v[w[i]]){
					w[i]=j;
				}
				if(b){
					u[j]=1;
				}
				continue;
			}
			v[j]=v[i]+1;
			self(self,j);
			if(v[w[j]]<v[w[i]]){
				w[i]=w[j];
			}
			if(b){
				if(w[j]==i){
					u[j]=1;
				}
				else{
					for(auto[k,_]:g[w[j]]){
						if(v[k]<v[w[j]]){
							continue;
						}
						u[k]=1;
					}
				}
			}
		}
	};
	v[1]=1;
	dfs(dfs,1);
	vector<int>ans;
	auto dfs2=[&](auto self,int i,int b)->void{
		if(b){
			ans.push_back(i);
		}
		for(auto[j,_]:g[i]){
			if(v[j]!=v[i]+1){
				continue;
			}
			self(self,j,b||u[j]);
		}
	};
	dfs2(dfs2,1,0);
	sort(ans.begin(),ans.end());
	cout<<ans.size()<<'\n';
	for(int i:ans){
		cout<<i<<' ';
	}
	cout<<'\n';
	return 0;
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted3ms1956 KiB
2Accepted9ms5084 KiB
subtask20/10
3Accepted3ms2500 KiB
4Accepted3ms2512 KiB
5Accepted3ms2864 KiB
6Wrong answer3ms2824 KiB
7Wrong answer3ms3172 KiB
subtask30/10
8Wrong answer3ms3248 KiB
9Wrong answer3ms3328 KiB
10Wrong answer3ms3400 KiB
11Wrong answer3ms3624 KiB
12Wrong answer4ms4428 KiB
subtask40/10
13Wrong answer7ms5640 KiB
14Wrong answer3ms3892 KiB
15Wrong answer3ms4240 KiB
16Wrong answer4ms4432 KiB
17Wrong answer157ms62960 KiB
18Wrong answer48ms20624 KiB
19Wrong answer64ms25816 KiB
20Wrong answer48ms23404 KiB
subtask50/10
21Wrong answer9ms13880 KiB
22Wrong answer3ms11688 KiB
23Accepted3ms11784 KiB
24Wrong answer3ms12060 KiB
25Wrong answer90ms45908 KiB
26Wrong answer9ms17292 KiB
27Wrong answer8ms17304 KiB
subtask60/60
28Wrong answer3ms15720 KiB
29Accepted3ms15972 KiB
30Wrong answer4ms16164 KiB
31Wrong answer4ms16444 KiB
32Wrong answer6ms16796 KiB
33Accepted6ms17120 KiB
34Accepted9ms18536 KiB
35Accepted10ms18732 KiB
36Accepted9ms18984 KiB
37Wrong answer172ms75564 KiB
38Wrong answer50ms33392 KiB
39Wrong answer48ms34304 KiB
40Wrong answer50ms35204 KiB
41Wrong answer48ms36088 KiB
42Wrong answer48ms37112 KiB
43Wrong answer48ms37880 KiB
44Wrong answer46ms38800 KiB
45Wrong answer64ms43888 KiB
46Wrong answer48ms41040 KiB
47Wrong answer48ms41900 KiB
48Wrong answer48ms43060 KiB
49Wrong answer48ms43928 KiB
50Wrong answer46ms44820 KiB