Submission #171522

# Submission time Handle Problem Language Result Execution time Memory
171522 2019-12-28T22:11:18 Z TadijaSebez 007 (CEOI14_007) C++11
0 / 100
320 ms 23672 KB
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
const int N=200050;
vector<int> E[N];
void BFS(int x, int n, int d[])
{
	for(int i=1;i<=n;i++) d[i]=-1;
	queue<int> q;
	q.push(x);
	d[x]=0;
	while(q.size())
	{
		int u=q.front();
		q.pop();
		for(int v:E[u]) if(d[v]==-1)
		{
			d[v]=d[u]+1;
			q.push(v);
		}
	}
}
int ds[N],dd[N];
int main()
{
	int n,m,s,d,a,b;
	scanf("%i %i",&n,&m);
	scanf("%i %i %i %i",&s,&d,&a,&b);
	for(int i=1,u,v;i<=m;i++) scanf("%i %i",&u,&v),E[u].pb(v),E[v].pb(u);
	BFS(s,n,ds);
	BFS(d,n,dd);
	//printf("%i %i %i %i\n",ds[a],ds[b],dd[a],dd[b]);
	int ans=min(dd[a]-ds[a],dd[b]-ds[b]);
	ans=max(ans,-1);
	printf("%i\n",ans);
	return 0;
}

Compilation message

007.cpp: In function 'int main()':
007.cpp:27:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%i %i",&n,&m);
  ~~~~~^~~~~~~~~~~~~~~
007.cpp:28:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%i %i %i %i",&s,&d,&a,&b);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
007.cpp:29:59: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(int i=1,u,v;i<=m;i++) scanf("%i %i",&u,&v),E[u].pb(v),E[v].pb(u);
                            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 6 ms 4984 KB Output is correct
2 Correct 6 ms 4984 KB Output is correct
3 Correct 6 ms 5112 KB Output is correct
4 Incorrect 6 ms 4984 KB Output isn't correct
5 Incorrect 6 ms 5112 KB Output isn't correct
6 Correct 6 ms 5112 KB Output is correct
7 Correct 6 ms 5112 KB Output is correct
8 Incorrect 6 ms 4984 KB Output isn't correct
9 Correct 6 ms 5112 KB Output is correct
10 Correct 6 ms 5112 KB Output is correct
11 Correct 6 ms 5112 KB Output is correct
12 Incorrect 6 ms 4984 KB Output isn't correct
13 Correct 6 ms 4984 KB Output is correct
14 Incorrect 6 ms 4984 KB Output isn't correct
15 Correct 6 ms 4984 KB Output is correct
16 Incorrect 6 ms 4984 KB Output isn't correct
17 Incorrect 6 ms 5116 KB Output isn't correct
18 Incorrect 6 ms 5112 KB Output isn't correct
19 Correct 6 ms 5112 KB Output is correct
20 Correct 6 ms 5112 KB Output is correct
21 Correct 6 ms 5112 KB Output is correct
22 Correct 6 ms 5112 KB Output is correct
23 Correct 6 ms 4984 KB Output is correct
24 Incorrect 7 ms 5112 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 31 ms 7160 KB Output is correct
2 Incorrect 41 ms 8056 KB Output isn't correct
3 Correct 33 ms 7288 KB Output is correct
4 Incorrect 45 ms 8284 KB Output isn't correct
5 Correct 30 ms 7032 KB Output is correct
6 Correct 32 ms 7288 KB Output is correct
7 Correct 38 ms 7532 KB Output is correct
8 Correct 37 ms 7544 KB Output is correct
9 Incorrect 52 ms 8312 KB Output isn't correct
10 Correct 182 ms 16860 KB Output is correct
11 Incorrect 71 ms 9648 KB Output isn't correct
12 Correct 90 ms 11000 KB Output is correct
13 Incorrect 76 ms 10104 KB Output isn't correct
14 Correct 65 ms 9208 KB Output is correct
15 Correct 98 ms 11000 KB Output is correct
16 Correct 103 ms 11384 KB Output is correct
17 Correct 88 ms 10616 KB Output is correct
18 Incorrect 85 ms 10636 KB Output isn't correct
19 Correct 124 ms 13016 KB Output is correct
20 Incorrect 230 ms 18936 KB Output isn't correct
21 Incorrect 134 ms 13304 KB Output isn't correct
22 Correct 118 ms 12152 KB Output is correct
23 Correct 139 ms 13204 KB Output is correct
24 Correct 130 ms 13176 KB Output is correct
25 Incorrect 166 ms 12664 KB Output isn't correct
26 Correct 137 ms 12296 KB Output is correct
27 Correct 137 ms 13432 KB Output is correct
28 Correct 137 ms 13304 KB Output is correct
29 Correct 196 ms 15352 KB Output is correct
30 Incorrect 254 ms 19932 KB Output isn't correct
31 Incorrect 161 ms 14676 KB Output isn't correct
32 Correct 143 ms 13304 KB Output is correct
33 Correct 141 ms 13564 KB Output is correct
34 Incorrect 146 ms 13944 KB Output isn't correct
35 Incorrect 134 ms 13724 KB Output isn't correct
36 Incorrect 148 ms 13900 KB Output isn't correct
37 Correct 191 ms 15112 KB Output is correct
38 Correct 169 ms 14892 KB Output is correct
39 Correct 185 ms 14960 KB Output is correct
40 Incorrect 240 ms 18552 KB Output isn't correct
41 Correct 320 ms 23672 KB Output is correct