Submission #95209

# Submission time Handle Problem Language Result Execution time Memory
95209 2019-01-28T14:46:56 Z Kewo 007 (CEOI14_007) C++14
0 / 100
298 ms 42556 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 << 0;
}
# Verdict Execution time Memory Grader output
1 Correct 25 ms 31608 KB Output is correct
2 Incorrect 25 ms 31608 KB Output isn't correct
3 Correct 25 ms 31736 KB Output is correct
4 Correct 25 ms 31608 KB Output is correct
5 Correct 24 ms 31656 KB Output is correct
6 Incorrect 25 ms 31608 KB Output isn't correct
7 Incorrect 24 ms 31608 KB Output isn't correct
8 Correct 29 ms 31608 KB Output is correct
9 Incorrect 29 ms 31608 KB Output isn't correct
10 Incorrect 30 ms 31608 KB Output isn't correct
11 Partially correct 30 ms 31608 KB Partially correct
12 Incorrect 25 ms 31608 KB Output isn't correct
13 Incorrect 28 ms 31864 KB Output isn't correct
14 Incorrect 30 ms 31608 KB Output isn't correct
15 Incorrect 26 ms 31608 KB Output isn't correct
16 Incorrect 25 ms 31608 KB Output isn't correct
17 Incorrect 25 ms 31736 KB Output isn't correct
18 Incorrect 25 ms 31692 KB Output isn't correct
19 Incorrect 25 ms 31736 KB Output isn't correct
20 Incorrect 25 ms 31736 KB Output isn't correct
21 Incorrect 25 ms 31736 KB Output isn't correct
22 Incorrect 24 ms 31608 KB Output isn't correct
23 Incorrect 25 ms 31692 KB Output isn't correct
24 Correct 25 ms 31736 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 50 ms 33400 KB Output isn't correct
2 Incorrect 57 ms 34132 KB Output isn't correct
3 Incorrect 51 ms 33528 KB Output isn't correct
4 Incorrect 64 ms 34452 KB Output isn't correct
5 Incorrect 48 ms 33400 KB Output isn't correct
6 Incorrect 53 ms 33528 KB Output isn't correct
7 Incorrect 52 ms 33784 KB Output isn't correct
8 Incorrect 51 ms 33760 KB Output isn't correct
9 Incorrect 64 ms 34556 KB Output isn't correct
10 Incorrect 153 ms 38904 KB Output isn't correct
11 Incorrect 75 ms 35448 KB Output isn't correct
12 Incorrect 103 ms 36228 KB Output isn't correct
13 Incorrect 87 ms 35780 KB Output isn't correct
14 Incorrect 71 ms 35192 KB Output isn't correct
15 Incorrect 90 ms 36216 KB Output isn't correct
16 Incorrect 88 ms 36452 KB Output isn't correct
17 Incorrect 98 ms 36048 KB Output isn't correct
18 Incorrect 78 ms 36088 KB Output isn't correct
19 Incorrect 114 ms 37240 KB Output isn't correct
20 Incorrect 197 ms 40044 KB Output isn't correct
21 Incorrect 106 ms 37624 KB Output isn't correct
22 Incorrect 103 ms 37028 KB Output isn't correct
23 Incorrect 106 ms 37624 KB Output isn't correct
24 Incorrect 123 ms 37628 KB Output isn't correct
25 Incorrect 126 ms 37232 KB Output isn't correct
26 Incorrect 91 ms 36984 KB Output isn't correct
27 Incorrect 113 ms 37752 KB Output isn't correct
28 Incorrect 147 ms 37624 KB Output isn't correct
29 Incorrect 178 ms 38472 KB Output isn't correct
30 Incorrect 249 ms 40592 KB Output isn't correct
31 Incorrect 150 ms 38580 KB Output isn't correct
32 Incorrect 129 ms 37548 KB Output isn't correct
33 Incorrect 137 ms 37724 KB Output isn't correct
34 Incorrect 142 ms 38012 KB Output isn't correct
35 Incorrect 110 ms 37860 KB Output isn't correct
36 Incorrect 126 ms 38136 KB Output isn't correct
37 Incorrect 151 ms 38904 KB Output isn't correct
38 Incorrect 163 ms 38520 KB Output isn't correct
39 Incorrect 181 ms 38648 KB Output isn't correct
40 Incorrect 236 ms 40352 KB Output isn't correct
41 Incorrect 298 ms 42556 KB Output isn't correct