Submission #95207

# Submission time Handle Problem Language Result Execution time Memory
95207 2019-01-28T14:42:39 Z Kewo 007 (CEOI14_007) C++14
0 / 100
328 ms 48888 KB
#include <bits/stdc++.h>
#define pb push_back
#define ppb pop_back
#define fi first
#define se second
#define mid ((x + y) / 2)
#define left (ind * 2)
#define right (ind * 2 + 1)
#define mp make_pair
#define timer ((double)clock() / CLOCKS_PER_SEC)
#define endl "\n"
#define spc " "
#define d1(x) cerr<<#x<<":"<<x<<endl
#define d2(x, y) cerr<<#x<<":"<<x<<" "<<#y<<":"<<y<<endl
#define d3(x, y, z) cerr<<#x<<":"<<x<<" "<<#y<<":"<<y<<" "<<#z<<":"<<z<<endl
#define fast_io() ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;

typedef long long int lli;
typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef pair<double, double> dd;

const int N = (int)(1e6 + 5);
const int LOG = (int)(20);

int n, m, cs1[N], cs2[N], s, d, a, b, ans;
vector<int> v[N];

void bfs1() {
	queue<int> q;
	q.push(s);
	memset(cs1, -1, sizeof cs1);
	cs1[s] = 0;
	while(!q.empty()) {
		int t = q.front();
		q.pop();
		for(auto i : v[t]) {
			if(cs1[i] == -1) {
				cs1[i] = cs1[t] + 1;
				q.push(i);
			}
		}
	}
}

void bfs2() {
	queue<int> q;
	q.push(d);
	memset(cs2, -1, sizeof cs1);
	cs2[d] = 0;
	while(!q.empty()) {
		int t = q.front();
		q.pop();
		for(auto i : v[t]) {
			if(cs2[i] == -1) {
				cs2[i] = cs2[t] + 1;
				q.push(i);
			}
		}
	}
}

int main() {
	fast_io();
	// freopen("inp.in", "r", stdin);
	
	cin >> n >> m;
	cin >> s >> d >> a >> b;
	for(int i = 1; i <= m; i++) {
		int aa, bb;
		cin >> aa >> bb;
		v[aa].pb(bb);
		v[bb].pb(aa);
	}

	bfs1();
	bfs2();
	ans = min(cs2[a] - cs1[a], cs2[b] - cs1[b]);
	ans = max(ans, 0);
	cout << ans;
}
# Verdict Execution time Memory Grader output
1 Correct 25 ms 31736 KB Output is correct
2 Correct 25 ms 31608 KB Output is correct
3 Correct 25 ms 31608 KB Output is correct
4 Incorrect 30 ms 31608 KB Output isn't correct
5 Incorrect 30 ms 31608 KB Output isn't correct
6 Correct 30 ms 31608 KB Output is correct
7 Correct 29 ms 31608 KB Output is correct
8 Incorrect 31 ms 31608 KB Output isn't correct
9 Correct 31 ms 31608 KB Output is correct
10 Correct 30 ms 31608 KB Output is correct
11 Correct 30 ms 31608 KB Output is correct
12 Incorrect 29 ms 31608 KB Output isn't correct
13 Correct 29 ms 31608 KB Output is correct
14 Incorrect 30 ms 31736 KB Output isn't correct
15 Correct 29 ms 31624 KB Output is correct
16 Incorrect 28 ms 31736 KB Output isn't correct
17 Incorrect 30 ms 31608 KB Output isn't correct
18 Incorrect 30 ms 31736 KB Output isn't correct
19 Correct 29 ms 31736 KB Output is correct
20 Correct 30 ms 31708 KB Output is correct
21 Correct 30 ms 31736 KB Output is correct
22 Correct 30 ms 31648 KB Output is correct
23 Correct 30 ms 31736 KB Output is correct
24 Incorrect 31 ms 31736 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 44 ms 33400 KB Output is correct
2 Incorrect 64 ms 34256 KB Output isn't correct
3 Correct 52 ms 33528 KB Output is correct
4 Incorrect 61 ms 34296 KB Output isn't correct
5 Correct 49 ms 33400 KB Output is correct
6 Correct 51 ms 33656 KB Output is correct
7 Correct 57 ms 33784 KB Output is correct
8 Correct 58 ms 33780 KB Output is correct
9 Incorrect 72 ms 34688 KB Output isn't correct
10 Correct 182 ms 42972 KB Output is correct
11 Incorrect 82 ms 35576 KB Output isn't correct
12 Correct 87 ms 36772 KB Output is correct
13 Incorrect 92 ms 35960 KB Output isn't correct
14 Incorrect 61 ms 35176 KB Output isn't correct
15 Correct 95 ms 36728 KB Output is correct
16 Correct 83 ms 36984 KB Output is correct
17 Correct 74 ms 36572 KB Output is correct
18 Incorrect 78 ms 36344 KB Output isn't correct
19 Correct 150 ms 38776 KB Output is correct
20 Incorrect 238 ms 44552 KB Output isn't correct
21 Incorrect 124 ms 38836 KB Output isn't correct
22 Correct 121 ms 37752 KB Output is correct
23 Correct 131 ms 38560 KB Output is correct
24 Correct 119 ms 38456 KB Output is correct
25 Incorrect 119 ms 38152 KB Output isn't correct
26 Correct 104 ms 37752 KB Output is correct
27 Correct 132 ms 38776 KB Output is correct
28 Correct 118 ms 38736 KB Output is correct
29 Correct 142 ms 40696 KB Output is correct
30 Incorrect 224 ms 45608 KB Output isn't correct
31 Incorrect 126 ms 39780 KB Output isn't correct
32 Correct 113 ms 38648 KB Output is correct
33 Correct 109 ms 38828 KB Output is correct
34 Incorrect 144 ms 39416 KB Output isn't correct
35 Incorrect 135 ms 38876 KB Output isn't correct
36 Incorrect 114 ms 39160 KB Output isn't correct
37 Correct 147 ms 40248 KB Output is correct
38 Correct 126 ms 40028 KB Output is correct
39 Correct 173 ms 40056 KB Output is correct
40 Incorrect 223 ms 43768 KB Output isn't correct
41 Correct 328 ms 48888 KB Output is correct