Submission #246174

# Submission time Handle Problem Language Result Execution time Memory
246174 2020-07-08T10:30:13 Z mieszko11b 007 (CEOI14_007) C++14
30 / 100
303 ms 23032 KB
#include <bits/stdc++.h>

using namespace std;

int n, m;
int s, d, a, b;
vector<int> G[200007];
int dist[200007];
bool vis[200007];

void run_bfs(int w) {
	memset(vis, 0, sizeof vis);
	vis[w] = 1;
	dist[w] = 0;
	queue<int> Q;
	Q.push(w);
	
	while(!Q.empty()) {
		int u=  Q.front();
		Q.pop();
		
		for(int v : G[u]) {
			if(!vis[v]) {
				vis[v] = 1;
				dist[v] = dist[u] + 1;
				Q.push(v);
			}
		}
	}
}

int main() {
	scanf("%d%d%d%d%d%d", &n, &m, &s, &d, &a, &b);
	while(m--) {
		int a, b;
		scanf("%d%d", &a, &b);
		G[a].push_back(b);
		G[b].push_back(a);
	}
	
	run_bfs(s);
	int sa = dist[a], sb = dist[b];
	run_bfs(d);
	int da = dist[a], db = dist[b];
	
	int val = min(da - sa, db - sb);
	if(val < 0) val = 0;
	
	printf("%d\n", val - 1);
	
	return 0;
}

Compilation message

007.cpp: In function 'int main()':
007.cpp:33:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d%d%d%d%d", &n, &m, &s, &d, &a, &b);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
007.cpp:36:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d", &a, &b);
   ~~~~~^~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Partially correct 9 ms 5248 KB Partially correct
2 Partially correct 8 ms 5248 KB Partially correct
3 Partially correct 8 ms 5248 KB Partially correct
4 Correct 10 ms 5248 KB Output is correct
5 Correct 8 ms 5248 KB Output is correct
6 Partially correct 8 ms 5248 KB Partially correct
7 Partially correct 7 ms 5248 KB Partially correct
8 Correct 7 ms 5248 KB Output is correct
9 Partially correct 8 ms 5248 KB Partially correct
10 Partially correct 8 ms 5248 KB Partially correct
11 Partially correct 7 ms 5248 KB Partially correct
12 Correct 7 ms 5248 KB Output is correct
13 Partially correct 8 ms 5248 KB Partially correct
14 Correct 7 ms 5248 KB Output is correct
15 Partially correct 7 ms 5248 KB Partially correct
16 Correct 7 ms 5248 KB Output is correct
17 Correct 7 ms 5248 KB Output is correct
18 Correct 7 ms 5248 KB Output is correct
19 Partially correct 7 ms 5248 KB Partially correct
20 Partially correct 8 ms 5248 KB Partially correct
21 Partially correct 8 ms 5248 KB Partially correct
22 Partially correct 7 ms 5248 KB Partially correct
23 Partially correct 7 ms 5248 KB Partially correct
24 Correct 8 ms 5248 KB Output is correct
# Verdict Execution time Memory Grader output
1 Partially correct 31 ms 7296 KB Partially correct
2 Correct 39 ms 7936 KB Output is correct
3 Partially correct 33 ms 7288 KB Partially correct
4 Correct 45 ms 8056 KB Output is correct
5 Partially correct 36 ms 7040 KB Partially correct
6 Partially correct 33 ms 7296 KB Partially correct
7 Partially correct 36 ms 7544 KB Partially correct
8 Partially correct 34 ms 7552 KB Partially correct
9 Correct 53 ms 8312 KB Output is correct
10 Partially correct 180 ms 16760 KB Partially correct
11 Correct 62 ms 9592 KB Output is correct
12 Partially correct 91 ms 10616 KB Partially correct
13 Correct 71 ms 9848 KB Output is correct
14 Correct 60 ms 9080 KB Output is correct
15 Partially correct 80 ms 10616 KB Partially correct
16 Partially correct 91 ms 11000 KB Partially correct
17 Partially correct 70 ms 10360 KB Partially correct
18 Correct 79 ms 10364 KB Output is correct
19 Partially correct 112 ms 12792 KB Partially correct
20 Correct 215 ms 18552 KB Output is correct
21 Correct 116 ms 12792 KB Output is correct
22 Partially correct 100 ms 11768 KB Partially correct
23 Partially correct 106 ms 12664 KB Partially correct
24 Partially correct 109 ms 12664 KB Partially correct
25 Correct 122 ms 12280 KB Output is correct
26 Partially correct 97 ms 11928 KB Partially correct
27 Partially correct 120 ms 12792 KB Partially correct
28 Partially correct 213 ms 12920 KB Partially correct
29 Partially correct 178 ms 14968 KB Partially correct
30 Correct 263 ms 19448 KB Output is correct
31 Correct 128 ms 13944 KB Output is correct
32 Partially correct 137 ms 12792 KB Partially correct
33 Partially correct 126 ms 13220 KB Partially correct
34 Correct 149 ms 13432 KB Output is correct
35 Correct 138 ms 13048 KB Output is correct
36 Correct 115 ms 13392 KB Output is correct
37 Partially correct 178 ms 14584 KB Partially correct
38 Partially correct 187 ms 14328 KB Partially correct
39 Partially correct 159 ms 14328 KB Partially correct
40 Correct 248 ms 18144 KB Output is correct
41 Partially correct 303 ms 23032 KB Partially correct