10136 | 2024-03-27 23:55:22 | 111 | Turista járatok | cpp17 | Wrong answer 0/100 | 170ms | 61104 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){
for(auto[k,_]:g[i]){
u[k]=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;
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 3ms | 1824 KiB | ||||
2 | Accepted | 10ms | 4772 KiB | ||||
subtask2 | 0/10 | ||||||
3 | Accepted | 3ms | 2280 KiB | ||||
4 | Accepted | 3ms | 2444 KiB | ||||
5 | Accepted | 3ms | 2660 KiB | ||||
6 | Wrong answer | 3ms | 2872 KiB | ||||
7 | Wrong answer | 3ms | 2976 KiB | ||||
subtask3 | 0/10 | ||||||
8 | Wrong answer | 3ms | 2960 KiB | ||||
9 | Wrong answer | 3ms | 2952 KiB | ||||
10 | Wrong answer | 3ms | 3088 KiB | ||||
11 | Wrong answer | 3ms | 3520 KiB | ||||
12 | Wrong answer | 4ms | 4528 KiB | ||||
subtask4 | 0/10 | ||||||
13 | Wrong answer | 8ms | 5536 KiB | ||||
14 | Wrong answer | 3ms | 3800 KiB | ||||
15 | Wrong answer | 3ms | 4016 KiB | ||||
16 | Wrong answer | 4ms | 4388 KiB | ||||
17 | Wrong answer | 156ms | 60384 KiB | ||||
18 | Wrong answer | 46ms | 15912 KiB | ||||
19 | Wrong answer | 65ms | 19956 KiB | ||||
20 | Wrong answer | 48ms | 16292 KiB | ||||
subtask5 | 0/10 | ||||||
21 | Wrong answer | 9ms | 6764 KiB | ||||
22 | Wrong answer | 3ms | 4456 KiB | ||||
23 | Accepted | 3ms | 4488 KiB | ||||
24 | Wrong answer | 3ms | 4636 KiB | ||||
25 | Wrong answer | 93ms | 35760 KiB | ||||
26 | Wrong answer | 9ms | 6752 KiB | ||||
27 | Wrong answer | 9ms | 6820 KiB | ||||
subtask6 | 0/60 | ||||||
28 | Wrong answer | 3ms | 4920 KiB | ||||
29 | Accepted | 3ms | 4812 KiB | ||||
30 | Wrong answer | 4ms | 5064 KiB | ||||
31 | Wrong answer | 4ms | 5312 KiB | ||||
32 | Wrong answer | 4ms | 5556 KiB | ||||
33 | Accepted | 6ms | 5960 KiB | ||||
34 | Accepted | 9ms | 7052 KiB | ||||
35 | Accepted | 10ms | 7424 KiB | ||||
36 | Accepted | 9ms | 7384 KiB | ||||
37 | Wrong answer | 170ms | 61104 KiB | ||||
38 | Wrong answer | 48ms | 16756 KiB | ||||
39 | Wrong answer | 46ms | 16776 KiB | ||||
40 | Wrong answer | 46ms | 16772 KiB | ||||
41 | Wrong answer | 46ms | 16788 KiB | ||||
42 | Wrong answer | 48ms | 16816 KiB | ||||
43 | Wrong answer | 48ms | 16808 KiB | ||||
44 | Wrong answer | 48ms | 16796 KiB | ||||
45 | Wrong answer | 64ms | 20600 KiB | ||||
46 | Wrong answer | 48ms | 16868 KiB | ||||
47 | Wrong answer | 48ms | 16772 KiB | ||||
48 | Wrong answer | 48ms | 16756 KiB | ||||
49 | Wrong answer | 48ms | 17052 KiB | ||||
50 | Wrong answer | 46ms | 17004 KiB |