记录详情

Wrong Answer

foo.cc: In function 'int main()':
foo.cc:27:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i=0;i<e2[no].size();i++){
               ~^~~~~~~~~~~~~~
foo.cc:37:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for(int j=0;j<e1[i].size();i++){
                ~^~~~~~~~~~~~~
foo.cc:53:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i=0;i<e1[no].size();i++){
               ~^~~~~~~~~~~~~~

自豪的采用 HydroJudge 进行评测(github.com/hydro-dev/HydroJudge)
{"receive":"2020-08-10T03:16:03.217Z","handle":"2020-08-10T03:16:03.217Z","cache_start":"2020-08-10T03:16:03.226Z","read_cases":"2020-08-10T03:16:03.389Z","judge":"2020-08-10T03:16:03.397Z","done":"2020-08-10T03:16:04.722Z"}
# 状态 耗时 内存占用
#1 Wrong Answer 读取到 2 ,应为 3 1ms 784.0 KiB
#2 Accepted 1ms 788.0 KiB
#3 Accepted 1ms 784.0 KiB
#4 Wrong Answer 读取到 3 ,应为 14 1ms 792.0 KiB
#5 Wrong Answer 读取到 3 ,应为 21 1ms 792.0 KiB
#6 Wrong Answer 读取到 2 ,应为 28 1ms 792.0 KiB
#7 Wrong Answer 读取到 4 ,应为 198 2ms 1.031 MiB
#8 Wrong Answer 读取到 3 ,应为 761 9ms 2.02 MiB
#9 Wrong Answer 读取到 35 ,应为 1581 4ms 1.352 MiB
#10 Wrong Answer 读取到 4 ,应为 2470 33ms 5.559 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(to);
				bo[to]=1;
			}
		}
	}
	for(int i=1;i<=n;i++){
		if(bo[i]){
			for(int j=0;j<e1[i].size();i++){
			 int to=e1[i][j];
			 if(!bo[to])
			   bo[i]=0;	
			}
		}
	}
	if(!bo[s]){
		puts("-1");
		return 0;
	} 
	vs[s]=1;
	q1.push(s);
	while(!q1.empty()){
		int no=q1.front();
		q1.pop();
		for(int i=0;i<e1[no].size();i++){
			int to=e1[no][i];
			if(bo[to]&&!vs[to]){
				q1.push(to);
				vs[to]=vs[no]+1;
			}
		}
	}
	printf("%d\n",vs[t]-1);
    return 0;
}

信息

递交者
类型
递交
题目
P1025 寻找道路
题目数据
下载
语言
C++
递交时间
2019-11-12 17:41:58
评测时间
2020-08-10 11:16:03
评测机
分数
20
总耗时
59ms
峰值内存
5.559 MiB