10138 | 2024-03-28 00:03:59 | 111 | Turista járatok | cpp17 | Wrong answer 10/100 | 164ms | 60080 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){
if(w[j]==i||w[j]==j){
u[j]=1;
}
else{
for(auto[k,_]:g[w[j]]){
if(v[k]<v[w[j]]){
continue;
}
u[k]=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||w[j]==j){
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 | 4768 KiB | ||||
subtask2 | 0/10 | ||||||
3 | Accepted | 3ms | 2272 KiB | ||||
4 | Accepted | 3ms | 2444 KiB | ||||
5 | Accepted | 3ms | 2824 KiB | ||||
6 | Wrong answer | 3ms | 2788 KiB | ||||
7 | Wrong answer | 3ms | 3160 KiB | ||||
subtask3 | 10/10 | ||||||
8 | Accepted | 3ms | 3136 KiB | ||||
9 | Accepted | 3ms | 3208 KiB | ||||
10 | Accepted | 3ms | 3456 KiB | ||||
11 | Accepted | 3ms | 3776 KiB | ||||
12 | Accepted | 4ms | 4552 KiB | ||||
subtask4 | 0/10 | ||||||
13 | Accepted | 7ms | 5504 KiB | ||||
14 | Accepted | 3ms | 3744 KiB | ||||
15 | Accepted | 3ms | 3996 KiB | ||||
16 | Accepted | 4ms | 4464 KiB | ||||
17 | Wrong answer | 164ms | 58864 KiB | ||||
18 | Wrong answer | 48ms | 15760 KiB | ||||
19 | Wrong answer | 61ms | 19716 KiB | ||||
20 | Wrong answer | 46ms | 16156 KiB | ||||
subtask5 | 0/10 | ||||||
21 | Accepted | 9ms | 6808 KiB | ||||
22 | Wrong answer | 3ms | 4844 KiB | ||||
23 | Accepted | 3ms | 4808 KiB | ||||
24 | Wrong answer | 3ms | 4820 KiB | ||||
25 | Wrong answer | 90ms | 35872 KiB | ||||
26 | Wrong answer | 8ms | 6876 KiB | ||||
27 | Wrong answer | 8ms | 7036 KiB | ||||
subtask6 | 0/60 | ||||||
28 | Wrong answer | 3ms | 5212 KiB | ||||
29 | Accepted | 3ms | 5228 KiB | ||||
30 | Accepted | 4ms | 5484 KiB | ||||
31 | Accepted | 4ms | 5832 KiB | ||||
32 | Wrong answer | 4ms | 5980 KiB | ||||
33 | Accepted | 6ms | 6152 KiB | ||||
34 | Accepted | 8ms | 7232 KiB | ||||
35 | Accepted | 9ms | 7508 KiB | ||||
36 | Accepted | 9ms | 7444 KiB | ||||
37 | Wrong answer | 164ms | 60080 KiB | ||||
38 | Wrong answer | 48ms | 17028 KiB | ||||
39 | Wrong answer | 46ms | 16900 KiB | ||||
40 | Wrong answer | 46ms | 16904 KiB | ||||
41 | Wrong answer | 46ms | 16904 KiB | ||||
42 | Wrong answer | 48ms | 17032 KiB | ||||
43 | Wrong answer | 48ms | 16900 KiB | ||||
44 | Wrong answer | 46ms | 16900 KiB | ||||
45 | Wrong answer | 64ms | 20672 KiB | ||||
46 | Wrong answer | 46ms | 16976 KiB | ||||
47 | Wrong answer | 48ms | 16900 KiB | ||||
48 | Wrong answer | 46ms | 16952 KiB | ||||
49 | Wrong answer | 46ms | 16936 KiB | ||||
50 | Wrong answer | 46ms | 16900 KiB |