10137 | 2024-03-28 00:00:07 | 111 | Turista járatok | cpp17 | Wrong answer 0/100 | 165ms | 60452 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]&&b){
u[i]=1;
}
if(v[j]>=v[i]-1){
continue;
}
if(v[j]<v[w[i]]){
w[i]=j;
}
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 | 9ms | 4560 KiB | ||||
subtask2 | 0/10 | ||||||
3 | Accepted | 3ms | 2236 KiB | ||||
4 | Accepted | 3ms | 2444 KiB | ||||
5 | Accepted | 3ms | 2664 KiB | ||||
6 | Wrong answer | 3ms | 2744 KiB | ||||
7 | Wrong answer | 3ms | 2864 KiB | ||||
subtask3 | 0/10 | ||||||
8 | Wrong answer | 3ms | 2748 KiB | ||||
9 | Wrong answer | 3ms | 2744 KiB | ||||
10 | Wrong answer | 3ms | 2880 KiB | ||||
11 | Wrong answer | 3ms | 3320 KiB | ||||
12 | Wrong answer | 4ms | 4308 KiB | ||||
subtask4 | 0/10 | ||||||
13 | Wrong answer | 7ms | 5124 KiB | ||||
14 | Wrong answer | 3ms | 3404 KiB | ||||
15 | Wrong answer | 3ms | 3656 KiB | ||||
16 | Wrong answer | 4ms | 3896 KiB | ||||
17 | Wrong answer | 165ms | 59684 KiB | ||||
18 | Wrong answer | 48ms | 15448 KiB | ||||
19 | Wrong answer | 64ms | 19096 KiB | ||||
20 | Wrong answer | 48ms | 15324 KiB | ||||
subtask5 | 0/10 | ||||||
21 | Wrong answer | 8ms | 6008 KiB | ||||
22 | Wrong answer | 3ms | 4044 KiB | ||||
23 | Accepted | 3ms | 4028 KiB | ||||
24 | Wrong answer | 3ms | 4300 KiB | ||||
25 | Wrong answer | 86ms | 35388 KiB | ||||
26 | Wrong answer | 8ms | 6324 KiB | ||||
27 | Wrong answer | 8ms | 6348 KiB | ||||
subtask6 | 0/60 | ||||||
28 | Wrong answer | 3ms | 4368 KiB | ||||
29 | Accepted | 3ms | 4384 KiB | ||||
30 | Wrong answer | 4ms | 4728 KiB | ||||
31 | Wrong answer | 4ms | 5012 KiB | ||||
32 | Wrong answer | 4ms | 5348 KiB | ||||
33 | Accepted | 6ms | 5624 KiB | ||||
34 | Accepted | 9ms | 6700 KiB | ||||
35 | Accepted | 9ms | 6848 KiB | ||||
36 | Accepted | 9ms | 6704 KiB | ||||
37 | Wrong answer | 165ms | 60452 KiB | ||||
38 | Wrong answer | 48ms | 16060 KiB | ||||
39 | Wrong answer | 48ms | 16208 KiB | ||||
40 | Wrong answer | 46ms | 16172 KiB | ||||
41 | Wrong answer | 48ms | 16180 KiB | ||||
42 | Wrong answer | 48ms | 16200 KiB | ||||
43 | Wrong answer | 48ms | 16420 KiB | ||||
44 | Wrong answer | 48ms | 16272 KiB | ||||
45 | Wrong answer | 64ms | 20344 KiB | ||||
46 | Wrong answer | 48ms | 16484 KiB | ||||
47 | Wrong answer | 48ms | 16504 KiB | ||||
48 | Wrong answer | 46ms | 16500 KiB | ||||
49 | Wrong answer | 46ms | 16504 KiB | ||||
50 | Wrong answer | 48ms | 16488 KiB |