这份代码为什么只能在c++98下编译
  • 板块灌水区
  • 楼主under_hole
  • 当前回复14
  • 已保存回复14
  • 发布时间2024/7/5 17:32
  • 上次更新2024/7/5 19:49:03
查看原帖
这份代码为什么只能在c++98下编译
1291460
under_hole楼主2024/7/5 17:32

rt,在洛谷在线ide上和该题-P5058上只能使用c++98才能编译。

代码如下:

#include<bits/stdc++.h>
using namespace std;
/*2024/7/5
*question id:p5058
*answer:
*idea:
*else:
*/
const int maxn=2000105;
struct Edge{
	int now=-1,next=-1;
}edges[maxn*5];
int nodes[maxn],dfn[maxn],low[maxn];
int n,x,y,root=0,cnt=0,Time=0;
set<int> st;
inline void add(int x,int y){
	edges[++cnt].now=y;
	edges[cnt].next=nodes[x];
	nodes[x]=cnt;
	return;
}
inline void tarjan(int np,int fa){
	int cutcnt=0;
	dfn[np]=low[np]=++Time;
	for(int i=nodes[np];i;i=edges[i].next){
		int Next=edges[i].now;
		if(Next==fa)continue;
		if(!dfn[Next]){
			tarjan(Next,np);
			low[np]=min(low[np],low[Next]);
			if(dfn[np]<=low[Next]&&(++cutcnt>=2||np!=root)){
				if(dfn[Next]<=dfn[y])st.insert(np);
			}
		}
		else low[np]=min(low[np],dfn[Next]);
	}
  return;
}
int main(){
	scanf("%d",&n);
	while(true){
		scanf("%d%d",&x,&y);
		if(x==0&&y==0)break;
		add(x,y);
		add(y,x);
	}
	scanf("%d%d",&x,&y);
	root=x;
	tarjan(x,0);
	if(st.size()==0)printf("No solution\n");
	else printf("%d\n",*st.begin());
	return 0;
}

这是样例输入:

5
2 1
2 5
1 4
5 3
2 3
5 1
0 0
4 2

这是样例输出:

1

而在Dev-c++上就没问题,本蒟蒻已经遇到两次了,求大佬解惑QAQ。

2024/7/5 17:32
加载中...