网站性能优化怎么做,西地那非副作用太强了,政务信息网站的建设的意义,本地服务器 wordpress题意#xff1a;中文题#xff0c;略 思路#xff1a;秦皇岛前就一直想学#xff0c;后来没怎么想通#xff0c;就算了。现在雅不是很懂#xff0c;一直似懂非懂的#xff0c;对于树分块的种类#xff0c;有位聚聚已经整理好了#xff08;传送门#xff09;#xff…题意中文题略 思路秦皇岛前就一直想学后来没怎么想通就算了。现在雅不是很懂一直似懂非懂的对于树分块的种类有位聚聚已经整理好了传送门其他的就是直接搜索分块 代码 #include bits/stdc.h
using namespace std;const int maxn1e47;
struct Edge
{int v,nxt;
}e[maxn1];
int top,stk[maxn];
int cnt,root[maxn];
int tot;
int belong[maxn],head[maxn];
int n,block;
void addedge(int x,int y)
{e[tot].vy;e[tot].nxthead[x];head[x]tot;
}
void dfs(int x,int pre)
{int bottomtop;for(int ihead[x];i;ie[i].nxt){if(e[i].vpre)continue;dfs(e[i].v,x);if(top-bottomblock){root[cnt]x;while(top!bottom)belong[stk[top--]]cnt;}}stk[top]x;
}
int main()
{scanf(%d%d,n,block);for(int i1,x,y;in;i){scanf(%d%d,x,y);addedge(x,y);addedge(y,x);}dfs(1,0);while(top)belong[stk[top--]]cnt;printf(%d\n,cnt);for(int i1;in;i)printf(%d ,belong[i]);puts();for(int i1;icnt;i)printf(%d ,root[i]);puts();return 0;
} 转载于:https://www.cnblogs.com/lalalatianlalu/p/9758661.html