Submission #132049

# Submission time Handle Problem Language Result Execution time Memory
132049 2019-07-18T08:46:29 Z bogdan10bos 007 (CEOI14_007) C++14
0 / 100
339 ms 23544 KB
/// 00:04 why?
#include <bits/stdc++.h>

using namespace std;

const int NMAX = 2e5 + 5;

int N, M, S, D, A, B;
vector<int> edg[NMAX];

vector<int> BFS(int start)
{
	vector<int> d(N + 1, 1 << 30);
	d[start] = 0;
	queue<int> q;
	q.push(start);
	while(!q.empty())
	{
		int nod = q.front();
		q.pop();
		for(auto nxt: edg[nod])
			if(d[nxt] > d[nod] + 1)
			{
				d[nxt] = d[nod] + 1;
				q.push(nxt);
			}
	}
	return d;
}

int main()
{
	//freopen("1.in", "r", stdin);
	scanf("%d%d", &N, &M);
	scanf("%d%d%d%d", &S, &D, &A, &B);
	for(int i = 1; i <= M; i++)
	{
		int x, y;
		scanf("%d%d", &x, &y);
		edg[x].push_back(y);
		edg[y].push_back(x);
	}

	auto dS = BFS(S);
	auto dD = BFS(D);

	if(dD[A] + 1 <= dS[A] || dD[B] + 1 <= dS[B])
	{
		printf("-1\n");
		exit(0);
	}

	int timp = min(dD[A] - dS[A], dD[B] - dS[B]);
	printf("%d\n", timp);
	return 0;
}

Compilation message

007.cpp: In function 'int main()':
007.cpp:34:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d", &N, &M);
  ~~~~~^~~~~~~~~~~~~~~~
007.cpp:35:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d%d%d", &S, &D, &A, &B);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
007.cpp:39:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d", &x, &y);
   ~~~~~^~~~~~~~~~~~~~~~
# 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 4988 KB Output is correct
4 Incorrect 6 ms 4984 KB Output isn't correct
5 Incorrect 6 ms 4984 KB Output isn't correct
6 Correct 6 ms 4984 KB Output is correct
7 Correct 6 ms 4984 KB Output is correct
8 Incorrect 6 ms 4988 KB Output isn't correct
9 Correct 6 ms 4984 KB Output is correct
10 Correct 6 ms 5112 KB Output is correct
11 Correct 6 ms 4984 KB Output is correct
12 Incorrect 6 ms 4984 KB Output isn't correct
13 Correct 6 ms 5112 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 4984 KB Output isn't correct
18 Incorrect 8 ms 4984 KB Output isn't correct
19 Correct 7 ms 5112 KB Output is correct
20 Correct 6 ms 5112 KB Output is correct
21 Correct 7 ms 5112 KB Output is correct
22 Correct 8 ms 4984 KB Output is correct
23 Correct 8 ms 4984 KB Output is correct
24 Incorrect 7 ms 5112 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 32 ms 7160 KB Output is correct
2 Incorrect 41 ms 8028 KB Output isn't correct
3 Correct 33 ms 7288 KB Output is correct
4 Incorrect 45 ms 8184 KB Output isn't correct
5 Correct 36 ms 7116 KB Output is correct
6 Correct 43 ms 7288 KB Output is correct
7 Correct 36 ms 7544 KB Output is correct
8 Correct 38 ms 7544 KB Output is correct
9 Incorrect 56 ms 8456 KB Output isn't correct
10 Correct 182 ms 16892 KB Output is correct
11 Incorrect 77 ms 9720 KB Output isn't correct
12 Correct 96 ms 11004 KB Output is correct
13 Incorrect 78 ms 10120 KB Output isn't correct
14 Correct 65 ms 9208 KB Output is correct
15 Correct 95 ms 11020 KB Output is correct
16 Correct 106 ms 11256 KB Output is correct
17 Correct 97 ms 10640 KB Output is correct
18 Incorrect 90 ms 10532 KB Output isn't correct
19 Correct 167 ms 13048 KB Output is correct
20 Incorrect 240 ms 18824 KB Output isn't correct
21 Incorrect 143 ms 13404 KB Output isn't correct
22 Correct 129 ms 12124 KB Output is correct
23 Correct 134 ms 13176 KB Output is correct
24 Correct 140 ms 13148 KB Output is correct
25 Incorrect 134 ms 12664 KB Output isn't correct
26 Correct 125 ms 12412 KB Output is correct
27 Correct 168 ms 13360 KB Output is correct
28 Correct 208 ms 13304 KB Output is correct
29 Correct 176 ms 15284 KB Output is correct
30 Incorrect 261 ms 19804 KB Output isn't correct
31 Incorrect 168 ms 14584 KB Output isn't correct
32 Correct 141 ms 13324 KB Output is correct
33 Correct 144 ms 13564 KB Output is correct
34 Incorrect 158 ms 14012 KB Output isn't correct
35 Incorrect 147 ms 13560 KB Output isn't correct
36 Incorrect 150 ms 13916 KB Output isn't correct
37 Correct 176 ms 15192 KB Output is correct
38 Correct 174 ms 14960 KB Output is correct
39 Correct 190 ms 14856 KB Output is correct
40 Incorrect 237 ms 18540 KB Output isn't correct
41 Correct 339 ms 23544 KB Output is correct