AMNS!
2025-02-06 10:27:14
发布于:上海
#include<iostream>
#include<memory>
#include<vector>
#include<array>
#include<queue>
using any_type = int;
using index_type = ::any_type;
using boolean = char;
constexpr ::any_type N=100001;
::any_type n,m,k;
::std::array<::std::vector<any_type>,N>map;
namespace DFS_VALUES{
::std::vector<any_type>stack;
::std::array<::any_type,N> pos;
size_t size(0);
}
template<class Type>
const Type* getAddress(const Type& x){
return &x;
}
void DFS(::any_type now,::any_type pre,const ::std::unique_ptr<boolean[]>&vis){
::any_type len(0);
::DFS_VALUES::stack.push_back(now);vis[now]=1;
::DFS_VALUES::pos.at(now)=::DFS_VALUES::stack.size();//=::DFS_VALUES::pos.at(pre)+1
for(::index_type idx:map[now])if(idx!=pre){
if(vis[idx]){
len=::DFS_VALUES::pos.at(now)-::DFS_VALUES::pos.at(idx);
if(len>=k){
printf("%d\n",len+1);
::index_type i(::DFS_VALUES::pos[idx]-1);
StartRange:
if(i>=::DFS_VALUES::pos.at(now))goto EndRange;
printf("%d ",::DFS_VALUES::stack.at(i++));
goto StartRange;
EndRange:exit(0);
}
}
else DFS(idx,now,vis);
}
::DFS_VALUES::stack.pop_back();
return;
}
int main(int argc,char*argv[],char**env){
::any_type u(0),v(0);
::index_type i(1);
::scanf("%d %d %d",::getAddress(n),::getAddress(m),::getAddress(k));
::std::unique_ptr<boolean[]>visit(new boolean[n+1]());
startRange2getEdge:
if(i>::m)goto endRange2getEdge;
::scanf("%d %d",::getAddress(u),::getAddress(v));
::map.at(u).push_back(v),::map.at(v).push_back(u);
++i;
goto startRange2getEdge;
endRange2getEdge:
::DFS(1,-1,visit);
return 0;
}
这里空空如也
有帮助,赞一个