# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
450020 |
2021-08-02T10:49:19 Z |
vanic |
007 (CEOI14_007) |
C++14 |
|
0 ms |
0 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(){2
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;
}
Compilation message
007.cpp: In function 'int binary()':
007.cpp:45:15: error: expected ';' before 'int'
45 | int binary(){2
| ^
| ;
46 | int lo=-1, hi=n, mid;
| ~~~
007.cpp:45:14: warning: statement has no effect [-Wunused-value]
45 | int binary(){2
| ^
007.cpp:47:8: error: 'lo' was not declared in this scope; did you mean 'log'?
47 | while(lo<hi){
| ^~
| log
007.cpp:47:11: error: 'hi' was not declared in this scope
47 | while(lo<hi){
| ^~
007.cpp:48:3: error: 'mid' was not declared in this scope
48 | mid=(lo+hi+1)/2;
| ^~~
007.cpp:56:9: error: 'lo' was not declared in this scope; did you mean 'log'?
56 | return lo;
| ^~
| log