Submission #95209

#TimeUsernameProblemLanguageResultExecution timeMemory
95209Kewo007 (CEOI14_007)C++14
0 / 100
298 ms42556 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...