/ Randle /

记录详情

Compile Error

/in/foo.cc: In function 'int spfa2()':
/in/foo.cc:78:7: error: reference to 'lock' is ambiguous
    if(lock[i]) continue;
       ^~~~
/in/foo.cc:34:26: note: candidates are: int lock [200010]
 int imp[1010],on[200010],lock[200010];
                          ^~~~
In file included from /usr/include/c++/6/future:39:0,
                 from /usr/include/x86_64-linux-gnu/c++/6/bits/stdc++.h:105,
                 from /in/foo.cc:1:
/usr/include/c++/6/mutex:540:5: note:                 template<class _L1, class _L2, class ... _L3> void std::lock(_L1&, _L2&, _L3& ...)
     lock(_L1& __l1, _L2& __l2, _L3&... __l3)
     ^~~~
/in/foo.cc: In function 'int main()':
/in/foo.cc:129:4: error: reference to 'lock' is ambiguous
    lock[on[i]]=1;lock[on[i]^1]=1;
    ^~~~
/in/foo.cc:34:26: note: candidates are: int lock [200010]
 int imp[1010],on[200010],lock[200010];
                          ^~~~
In file included from /usr/include/c++/6/future:39:0,
                 from /usr/include/x86_64-linux-gnu/c++/6/bits/stdc++.h:105,
                 from /in/foo.cc:1:
/usr/include/c++/6/mutex:540:5: note:                 template<class _L1, class _L2, class ... _L3> void std::lock(_L1&, _L2&, _L3& ...)
     lock(_L1& __l1, _L2& __l2, _L3&... __l3)
     ^~~~
/in/foo.cc:129:18: error: reference to 'lock' is ambiguous
    lock[on[i]]=1;lock[on[i]^1]=1;
                  ^~~~
/in/foo.cc:34:26: note: candidates are: int lock [200010]
 int imp[1010],on[200010],lock[200010];
                          ^~~~
In file included from /usr/include/c++/6/future:39:0,
                 from /usr/include/x86_64-linux-gnu/c++/6/bits/stdc++.h:105,
                 from /in/foo.cc:1:
/usr/include/c++/6/mutex:540:5: note:                 template<class _L1, class _L2, class ... _L3> void std::lock(_L1&, _L2&, _L3& ...)
     lock(_L1& __l1, _L2& __l2, _L3&... __l3)
     ^~~~
/in/foo.cc:131:13: error: reference to 'lock' is ambiguous
             lock[on[i]]=0;lock[on[i]^1]=0;
             ^~~~
/in/foo.cc:34:26: note: candidates are: int lock [200010]
 int imp[1010],on[200010],lock[200010];
                          ^~~~
In file included from /usr/include/c++/6/future:39:0,
                 from /usr/include/x86_64-linux-gnu/c++/6/bits/stdc++.h:105,
                 from /in/foo.cc:1:
/usr/include/c++/6/mutex:540:5: note:                 template<class _L1, class _L2, class ... _L3> void std::lock(_L1&, _L2&, _L3& ...)
     lock(_L1& __l1, _L2& __l2, _L3&... __l3)
     ^~~~
/in/foo.cc:131:27: error: reference to 'lock' is ambiguous
             lock[on[i]]=0;lock[on[i]^1]=0;
                           ^~~~
/in/foo.cc:34:26: note: candidates are: int lock [200010]
 int imp[1010],on[200010],lock[200010];
                          ^~~~
In file included from /usr/include/c++/6/future:39:0,
                 from /usr/include/x86_64-linux-gnu/c++/6/bits/stdc++.h:105,
                 from /in/foo.cc:1:
/usr/include/c++/6/mutex:540:5: note:                 template<class _L1, class _L2, class ... _L3> void std::lock(_L1&, _L2&, _L3& ...)
     lock(_L1& __l1, _L2& __l2, _L3&... __l3)
     ^~~~

代码

#include <bits/stdc++.h>
using namespace std;

inline int read()
{
	char ch=getchar();
	int x=0;
	while(!isdigit(ch))
		ch=getchar();
	while(isdigit(ch))
	{
		x=x*10+ch-'0';
		ch=getchar();
	}
	return x;
}

struct edge
{
	int to,nex,l;
	double p;
}e[200010];
int point[1010],cnt=-1;

inline const void add(int x,int y,int l,double p)
{
	e[++cnt].to=y;
	e[cnt].nex=point[x];
	point[x]=cnt;
	e[cnt].l=l;
	e[cnt].p=p;
}
int n,m; 
int imp[1010],on[200010],lock[200010];
inline int spfa1()
{
	int q[10000],head=1,tail=0;
	int d[1010],vis[1010],i,u,v;
	memset(d,0x3f,sizeof(d));
	memset(vis,0,sizeof(vis));
	q[++tail]=1,vis[1]=1,d[1]=0;
	while(head<=tail)
	{
		u=q[head++];
		vis[u]=0;
		for(i=point[u];i!=-1;i=e[i].nex)
		{
			v=e[i].to;
			if(d[v]>d[u]+e[i].l)
			{		
				imp[v]=i;
				d[v]=d[u]+e[i].l;
				if(!vis[v])
				{
					vis[v]=1;
					q[++tail]=v;
				}
			}
		}
	}
	if(d[n]==d[0])
		return 0;
	return d[n];
}
inline int spfa2()
{
	int q[10000],head=1,tail=0;
	int d[1010],vis[1010],i,u,v;
	memset(d,0x3f,sizeof(d));
	memset(vis,0,sizeof(vis));
	q[++tail]=1,vis[1]=1,d[1]=0;
	while(head<=tail)
	{
		u=q[head++];
		vis[u]=0;
		for(i=point[u];i!=-1;i=e[i].nex)
		{
			if(lock[i]) continue;
			v=e[i].to;
			if(d[v]>d[u]+e[i].l)
			{
				d[v]=d[u]+e[i].l;
				if(!vis[v])
				{
					vis[v]=1;
					q[++tail]=v;
				}
			}
		}
	}
	if(d[n]==d[0])
		return 0;
	return d[n];
}

int main()
{
	int i,j,k,l;
	double p;
	memset(point,-1,sizeof(point));
	memset(imp,-1,sizeof(imp));
	n=read(),m=read();
	
	for(i=1;i<=m;i++)
	{
		j=read(),k=read(),l=read(),cin>>p;
		add(j,k,l,p);
		add(k,j,l,p);
	}
	
	int a=spfa1();
	if(a==0)
	{
		cout<<"0.0000000";
		exit(0);
	}
	double tot=0,ans=0;
	cnt=0;
    for(i=2;i<=n;i++)
    	if(imp[i]!=-1)
    	{
    		tot+=e[imp[i]].p;
			on[++cnt]=imp[i];
		}
    ans+=1.0*a*(1-tot);
	for(i=1;i<=cnt;i++)
		if(e[on[i]].p>0)
		{
			lock[on[i]]=1;lock[on[i]^1]=1;
            ans+=1.0*spfa2()*e[on[i]].p;
            lock[on[i]]=0;lock[on[i]^1]=0;
		}
	printf("%.7lf",ans);	
}

信息

递交者
类型
递交
题目
从中国到阿布拉斯基索沃尔朗特乎斯德麦尔维(原创)
题目数据
下载
语言
C++
递交时间
2017-11-07 11:27:49
评测时间
2017-11-07 11:27:49
评测机
分数
0
总耗时
0ms
峰值内存
0 Bytes