Submission #450021

# Submission time Handle Problem Language Result Execution time Memory
450021 2021-08-02T10:49:37 Z vanic 007 (CEOI14_007) C++14
0 / 100
1000 ms 15156 KB
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <cstring>
#include <queue>
#include <cassert>
#include <set>
#include <array>

using namespace std;

const int maxn=2e5+5;

vector < int > ms[maxn];
int a, b, c, d;
bool bio[2][maxn];
int n, m;


bool provjeri(int x){
	set < array < int, 3 > > s;
	memset(bio, 0, sizeof(bio));
	s.insert({0, 0, b});
	s.insert({x, 1, a});
	array < int, 3 > y;
	while(!s.empty()){
		y=*s.begin();
		s.erase(s.begin());
		if(!y[1] && bio[1][y[2]]){
			continue;
		}
		bio[y[1]][y[2]]=1;
		for(int i=0; i<(int)ms[y[2]].size(); i++){
			if(!bio[y[1]][ms[y[2]][i]]){
				bio[y[1]][ms[y[2]][i]]=1;
				s.insert({y[0]+1, y[1], ms[y[2]][i]});
			}
		}
	}
	return !bio[0][c] && !bio[0][d];
}

int binary(){
	int lo=-1, hi=n, mid;
	while(lo<hi){
		mid=(lo+hi+1)/2;
		if(provjeri(mid)){
			lo=mid;
		}
		else{
			hi=mid-1;
		}
	}
	return lo;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin >> n >> m;
	cin >> a >> b >> c >> d;
	a--; b--; c--; d--;
	assert(a!=b && a!=c && a!=d);
	int x, y;
	for(int i=0; i<m; i++){
		cin >> x >> y;
		x--; y--;
		ms[x].push_back(y);
		ms[y].push_back(x);
	}
	cout << binary() << '\n';
	return 0;
}
# Verdict Execution time Memory Grader output
1 Partially correct 3 ms 5324 KB Partially correct
2 Incorrect 3 ms 5324 KB Output isn't correct
3 Partially correct 4 ms 5336 KB Partially correct
4 Partially correct 3 ms 5404 KB Partially correct
5 Partially correct 4 ms 5324 KB Partially correct
6 Correct 5 ms 5324 KB Output is correct
7 Incorrect 4 ms 5324 KB Output isn't correct
8 Partially correct 4 ms 5324 KB Partially correct
9 Incorrect 4 ms 5324 KB Output isn't correct
10 Incorrect 4 ms 5324 KB Output isn't correct
11 Incorrect 4 ms 5324 KB Output isn't correct
12 Partially correct 4 ms 5324 KB Partially correct
13 Incorrect 5 ms 5324 KB Output isn't correct
14 Incorrect 4 ms 5324 KB Output isn't correct
15 Correct 4 ms 5324 KB Output is correct
16 Partially correct 5 ms 5324 KB Partially correct
17 Partially correct 6 ms 5324 KB Partially correct
18 Partially correct 6 ms 5432 KB Partially correct
19 Incorrect 6 ms 5324 KB Output isn't correct
20 Incorrect 6 ms 5324 KB Output isn't correct
21 Correct 5 ms 5324 KB Output is correct
22 Correct 6 ms 5436 KB Output is correct
23 Correct 6 ms 5420 KB Output is correct
24 Partially correct 5 ms 5324 KB Partially correct
# Verdict Execution time Memory Grader output
1 Incorrect 313 ms 6732 KB Output isn't correct
2 Partially correct 314 ms 7248 KB Partially correct
3 Incorrect 359 ms 6852 KB Output isn't correct
4 Partially correct 335 ms 7312 KB Partially correct
5 Correct 363 ms 6712 KB Output is correct
6 Correct 222 ms 6852 KB Output is correct
7 Correct 374 ms 6968 KB Output is correct
8 Correct 403 ms 6988 KB Output is correct
9 Partially correct 343 ms 7328 KB Partially correct
10 Incorrect 704 ms 11564 KB Output isn't correct
11 Partially correct 959 ms 8256 KB Partially correct
12 Execution timed out 1085 ms 9240 KB Time limit exceeded
13 Partially correct 774 ms 8524 KB Partially correct
14 Correct 690 ms 8024 KB Output is correct
15 Incorrect 916 ms 9180 KB Output isn't correct
16 Execution timed out 1079 ms 9400 KB Time limit exceeded
17 Execution timed out 1074 ms 8828 KB Time limit exceeded
18 Execution timed out 1084 ms 8900 KB Time limit exceeded
19 Incorrect 984 ms 9976 KB Output isn't correct
20 Execution timed out 1093 ms 12868 KB Time limit exceeded
21 Execution timed out 1079 ms 10336 KB Time limit exceeded
22 Execution timed out 1088 ms 9788 KB Time limit exceeded
23 Execution timed out 1091 ms 10412 KB Time limit exceeded
24 Incorrect 1000 ms 10328 KB Output isn't correct
25 Execution timed out 1094 ms 10008 KB Time limit exceeded
26 Execution timed out 1091 ms 9740 KB Time limit exceeded
27 Execution timed out 1080 ms 10420 KB Time limit exceeded
28 Execution timed out 1089 ms 10600 KB Time limit exceeded
29 Execution timed out 1071 ms 11184 KB Time limit exceeded
30 Execution timed out 1090 ms 13344 KB Time limit exceeded
31 Execution timed out 1071 ms 11052 KB Time limit exceeded
32 Execution timed out 1073 ms 10368 KB Time limit exceeded
33 Execution timed out 1083 ms 10508 KB Time limit exceeded
34 Execution timed out 1099 ms 10824 KB Time limit exceeded
35 Execution timed out 1058 ms 10460 KB Time limit exceeded
36 Execution timed out 1071 ms 10768 KB Time limit exceeded
37 Execution timed out 1077 ms 11488 KB Time limit exceeded
38 Execution timed out 1094 ms 11340 KB Time limit exceeded
39 Execution timed out 1067 ms 11364 KB Time limit exceeded
40 Execution timed out 1080 ms 12892 KB Time limit exceeded
41 Execution timed out 1090 ms 15156 KB Time limit exceeded