10135 | 2024-03-27 23:53:13 | 111 | Turista járatok | cpp17 | Wrong answer 0/100 | 172ms | 75564 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;
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 3ms | 1956 KiB | ||||
2 | Accepted | 9ms | 5084 KiB | ||||
subtask2 | 0/10 | ||||||
3 | Accepted | 3ms | 2500 KiB | ||||
4 | Accepted | 3ms | 2512 KiB | ||||
5 | Accepted | 3ms | 2864 KiB | ||||
6 | Wrong answer | 3ms | 2824 KiB | ||||
7 | Wrong answer | 3ms | 3172 KiB | ||||
subtask3 | 0/10 | ||||||
8 | Wrong answer | 3ms | 3248 KiB | ||||
9 | Wrong answer | 3ms | 3328 KiB | ||||
10 | Wrong answer | 3ms | 3400 KiB | ||||
11 | Wrong answer | 3ms | 3624 KiB | ||||
12 | Wrong answer | 4ms | 4428 KiB | ||||
subtask4 | 0/10 | ||||||
13 | Wrong answer | 7ms | 5640 KiB | ||||
14 | Wrong answer | 3ms | 3892 KiB | ||||
15 | Wrong answer | 3ms | 4240 KiB | ||||
16 | Wrong answer | 4ms | 4432 KiB | ||||
17 | Wrong answer | 157ms | 62960 KiB | ||||
18 | Wrong answer | 48ms | 20624 KiB | ||||
19 | Wrong answer | 64ms | 25816 KiB | ||||
20 | Wrong answer | 48ms | 23404 KiB | ||||
subtask5 | 0/10 | ||||||
21 | Wrong answer | 9ms | 13880 KiB | ||||
22 | Wrong answer | 3ms | 11688 KiB | ||||
23 | Accepted | 3ms | 11784 KiB | ||||
24 | Wrong answer | 3ms | 12060 KiB | ||||
25 | Wrong answer | 90ms | 45908 KiB | ||||
26 | Wrong answer | 9ms | 17292 KiB | ||||
27 | Wrong answer | 8ms | 17304 KiB | ||||
subtask6 | 0/60 | ||||||
28 | Wrong answer | 3ms | 15720 KiB | ||||
29 | Accepted | 3ms | 15972 KiB | ||||
30 | Wrong answer | 4ms | 16164 KiB | ||||
31 | Wrong answer | 4ms | 16444 KiB | ||||
32 | Wrong answer | 6ms | 16796 KiB | ||||
33 | Accepted | 6ms | 17120 KiB | ||||
34 | Accepted | 9ms | 18536 KiB | ||||
35 | Accepted | 10ms | 18732 KiB | ||||
36 | Accepted | 9ms | 18984 KiB | ||||
37 | Wrong answer | 172ms | 75564 KiB | ||||
38 | Wrong answer | 50ms | 33392 KiB | ||||
39 | Wrong answer | 48ms | 34304 KiB | ||||
40 | Wrong answer | 50ms | 35204 KiB | ||||
41 | Wrong answer | 48ms | 36088 KiB | ||||
42 | Wrong answer | 48ms | 37112 KiB | ||||
43 | Wrong answer | 48ms | 37880 KiB | ||||
44 | Wrong answer | 46ms | 38800 KiB | ||||
45 | Wrong answer | 64ms | 43888 KiB | ||||
46 | Wrong answer | 48ms | 41040 KiB | ||||
47 | Wrong answer | 48ms | 41900 KiB | ||||
48 | Wrong answer | 48ms | 43060 KiB | ||||
49 | Wrong answer | 48ms | 43928 KiB | ||||
50 | Wrong answer | 46ms | 44820 KiB |