254732026-02-20 11:32:27abcdElfogáscpp17Wrong answer 0/5057ms3392 KiB
#include <bits/stdc++.h>
using namespace std;

const int maxn=20001;
vector<int> adj[maxn];

int tin[maxn],low[maxn],par[maxn],timer=1;
bool is[maxn],can[maxn];
vector<int> ans;
int dest,sep;

void dfs(int v,int p){
    par[v]=p;
    tin[v]=low[v]=timer++;
    int children=0;
    for(int to:adj[v]){
        if(to==p)continue;
        if(tin[to])low[v]=min(low[v],tin[to]);
        else{
            dfs(to,v);
            low[v]=min(low[v],low[to]);
            children++;
            if(p!=-1&&low[to]>=tin[v])is[v]=true;
            if(to==sep&&low[to]<tin[v])sep=v;
        }
    }
    if(p==-1&&children>1)is[v]=true;
}

void dfs2(int v){
    can[v]=true;
    ans.push_back(v);
    for(int to:adj[v]){
        if(par[to]==v){
            dfs2(to);
        }
    }
}

int main(){
    int n,m,u;cin>>n>>m>>u>>dest;
    for(int i=0;i<m;i++){
        int a,b;cin>>a>>b;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    sep=dest;
    dfs(u,-1);
    dfs2(sep);
    cout<<sep<<'\n';
    cout<<ans.size()<<'\n';
    for(int x:ans)cout<<x<<' ';cout<<'\n';
}
SubtaskSumTestVerdictTimeMemory
base0/50
1Wrong answer0/01ms820 KiB
2Wrong answer0/08ms1332 KiB
3Wrong answer0/21ms828 KiB
4Wrong answer0/22ms820 KiB
5Wrong answer0/22ms820 KiB
6Wrong answer0/22ms836 KiB
7Wrong answer0/32ms864 KiB
8Wrong answer0/32ms820 KiB
9Wrong answer0/34ms896 KiB
10Wrong answer0/34ms820 KiB
11Wrong answer0/37ms1076 KiB
12Wrong answer0/38ms1332 KiB
13Wrong answer0/38ms1288 KiB
14Wrong answer0/39ms1332 KiB
15Wrong answer0/39ms1588 KiB
16Wrong answer0/339ms2092 KiB
17Wrong answer0/341ms2356 KiB
18Wrong answer0/341ms2364 KiB
19Wrong answer0/341ms2432 KiB
20Wrong answer0/357ms3392 KiB