记录详情

Wrong Answer

/in/foo.cc: In function 'int main()':
/in/foo.cc:27:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i=0;i<e2[no].size();i++){
               ~^~~~~~~~~~~~~~
/in/foo.cc:45:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i=0;i<e1[no].size();i++){
               ~^~~~~~~~~~~~~~
# 状态 耗时 内存占用
#1 Wrong Answer 2ms 736.0 KiB
#2 Wrong Answer 2ms 728.0 KiB
#3 Wrong Answer 1ms 740.0 KiB
#4 Wrong Answer 1ms 732.0 KiB
#5 Wrong Answer 2ms 740.0 KiB
#6 Wrong Answer 2ms 732.0 KiB
#7 Wrong Answer 3ms 864.0 KiB
#8 Wrong Answer 12ms 1.523 MiB
#9 Wrong Answer 4ms 1.199 MiB
#10 Wrong Answer 45ms 3.609 MiB

代码

#include<bits/stdc++.h>
using namespace std;
int n,m,s,t;
inline int read(){
	int x=0,f=1;char c=getchar();
	while(c<'0') f^=(c=='-'),c=getchar();
	while(c>'/') x=(x<<3)+(x<<1)+(c^'0'),c=getchar();
	return f?x:-x;
}
vector<int>e1[10010],e2[10010];  
int bo[10010],vs[10010];
int main(){
	n=read();m=read();
	for(int i=1;i<=m;i++){
	 int u=read(),v=read();
	 e1[u].push_back(v);
	 e2[v].push_back(u);	
	}
	queue<int> q1; 
	s=read();
	t=read();
	bo[t]=1;
	q1.push(t);
	while(!q1.empty()){
		int no=q1.front();
		q1.pop();
		for(int i=0;i<e2[no].size();i++){
			int to=e2[no][i];
			if(!bo[to]){
				q1.push(t);
				bo[to]=1;
			}
		}
	}
	if(!bo[s]){
		puts("-1");
		return 0;
	}
	queue<int> q2; 
	vs[s]=1;
	q2.push(s);
	while(!q2.empty()){
		int no=q2.front();
		q2.pop();
		for(int i=0;i<e1[no].size();i++){
			int to=e1[no][i];
			if(bo[to]&&!vs[to]){
				q2.push(t);
				vs[to]=vs[no]+1;
			}
		}
	}
	printf("%d\n",vs[t]-1);
    return 0;
}

信息

递交者
类型
递交
题目
P1025 寻找道路
题目数据
下载
语言
C++
递交时间
2019-11-12 17:21:52
评测时间
2020-08-10 11:15:53
评测机
分数
0
总耗时
79ms
峰值内存
3.609 MiB