/ Randle /

记录详情

Compile Error

/in/foo.cc:39:5: error: 'int time' redeclared as different kind of symbol
 int time,dfn[maxn],low[maxn],scc,f[maxn],val[maxn];
     ^~~~
In file included from /usr/include/pthread.h:24:0,
                 from /usr/include/x86_64-linux-gnu/c++/6/bits/gthr-default.h:35,
                 from /usr/include/x86_64-linux-gnu/c++/6/bits/gthr.h:148,
                 from /usr/include/c++/6/ext/atomicity.h:35,
                 from /usr/include/c++/6/bits/ios_base.h:39,
                 from /usr/include/c++/6/ios:42,
                 from /usr/include/c++/6/ostream:38,
                 from /usr/include/c++/6/iostream:39,
                 from /in/foo.cc:2:
/usr/include/time.h:192:15: note: previous declaration 'time_t time(time_t*)'
 extern time_t time (time_t *__timer) __THROW;
               ^~~~
/in/foo.cc: In function 'void tarjan(int)':
/in/foo.cc:41:22: warning: ISO C++ forbids incrementing a pointer of type 'time_t (*)(time_t*) throw () {aka long int (*)(long int*) throw ()}' [-Wpointer-arith]
  dfn[a] = low[a] = ++time;
                      ^~~~
/in/foo.cc:41:22: error: lvalue required as increment operand

代码

#include <stdio.h>
#include <iostream>
#include <cstring>
const int maxn = 10e5+5;
using namespace std;
class stack {
		int a[maxn];
		int visit[maxn];
		int rare;
	public:
		void init() {
			memset(visit,0,sizeof(visit));
			rare= 0;
		}
	public:
		void push(int x) {
			visit[x] = 1;
			a[rare++] = x;
		}
	public:
		int pop() {
			int ret = a[--rare];
			visit[ret] = 0;
			return ret;
		}
	public:
		int isin(int x) {
			return visit[x];
		}
};
struct edge {
	int from,to;
} edges[maxn];
int in[maxn],head[maxn],nex[maxn],dis[maxn],q,diss[maxn];
inline void connect(int x,int y) {
	nex[++q] = head[x],dis[q] = y,head[x] = q;
}
stack s;
int time,dfn[maxn],low[maxn],scc,f[maxn],val[maxn];
void tarjan(int a) {
	dfn[a] = low[a] = ++time;
	s.push(a);
	for(int i = head[a]; i; i=nex[i]) {
		if(!dfn[dis[i]]) {
			tarjan(dis[i]);
			low[a] = min(low[a],low[dis[i]]);
		} else if(s.isin(dis[i])) low[a] = min(low[a],dfn[dis[i]]);
	}
	if(dfn[a]==low[a]) {
		scc++;
		do {
			a = s.pop();
			f[a] = scc;
			val[scc] ++;
		} while(dfn[a]!=low[a]);
	}
}
int que[maxn],rare,hh;
int main() {
	s.init();
	int n,m;
	scanf("%d%d",&n,&m);
	for(int i = 1; i<=m; i++) {
		int x,y;
		scanf("%d%d",&x,&y);	
		connect(y,x);
		edges[i].from = y,edges[i].to  = x;
	}
	int ans = 0;
	for(int i = 1; i<=n; i++) if(!dfn[i]) tarjan(i);
	memset(head,0,sizeof(head));
	memset(nex,0,sizeof(nex));
	memset(dis,0,sizeof(dis));
	q = 0;
	for(int i = 1; i<=m; i++)
		if(f[edges[i].from]!=f[edges[i].to]) {
			connect(f[edges[i].from],f[edges[i].to]);
			in[f[edges[i].to]]++;
		}
	for(int i = 1;i<=scc;i++){
		if(in[i]==0){
			diss[i] = val[i];
			ans = max(ans,val[i]);
			que[rare++] = i;
		}
	}
	
	while(hh<rare){
		int a = que[hh++];
		for(int i = head[a];i;i = nex[i]){
			int to = dis[i];
			diss[to] = max(diss[to],diss[a]+val[to]);
			ans = max(ans,diss[to]);
			in[to]--;
			if(in[to]==0){
				que[rare++] = to;
			}
		}
	}
	cout<<ans;
	return 0;
}

信息

递交者
类型
递交
题目
BOMB炸弹(CQ直辖市noip模拟赛联考) T1
题目数据
下载
语言
C++
递交时间
2017-11-04 18:36:07
评测时间
2017-11-04 18:36:07
评测机
分数
0
总耗时
0ms
峰值内存
0 Bytes