Submission #110765

#TimeUsernameProblemLanguageResultExecution timeMemory
110765MAMBA007 (CEOI14_007)C++17
0 / 100
40 ms23932 KiB
#include <bits/stdc++.h> using namespace std; #define rep(i , j , k) for (int i = j; i < (int)k; i++) #define pb push_back #define mt make_tuple #define for_all(x) x.begin(),x.end() typedef long long ll; typedef pair<int , int> pii; typedef pair<ll, ll> pll; typedef vector<int> vi; typedef long double ld; typedef complex<ld> point; inline void fileIO(string s) { freopen((s + ".in").c_str(), "r", stdin); freopen((s + ".out").c_str(), "w", stdout); } template<class T , class S> inline bool smin(T &a, S b) { return (T)b < a ? a = b , 1 : 0; } template<class T , class S> inline bool smax(T &a, S b) { return a < (T)b ? a = b , 1 : 0; } constexpr int N = 1e6 + 10; constexpr int MOD = 1e9 + 7; template<typename T> inline T mod(T &v) { return v = (v % MOD + MOD) % MOD; } template<typename S, typename T> inline S add(S &l, T r) { return mod(l += r); } ll po(ll v, ll u) { return u ? po(v * v % MOD , u >> 1) * (u & 1 ? v : 1) % MOD : 1; } int n , m; int s , t , a , b, dist[N]; vector<int> adj[N]; int L , R , Q[N]; void bfs(int so) { memset(dist , -1, sizeof(dist)); dist[so] = 0; L = 0, R = 1; Q[0] = so; while (L < R) { int me = Q[L++]; for (auto e : adj[me]) if (!~dist[e]) { dist[e] = dist[me] + 1; Q[R++] = e; } } } int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); #ifndef LOCAL // fileIO("forbidden1"); #endif cout << -1 << endl; return 0; cin >> n >> m >> s >> t >> a >> b; rep(i , 0 , m) { int u , v; cin >> u >> v; adj[u].pb(v); adj[v].pb(u); } bfs(s); int A = dist[a]; int B = dist[b]; bfs(t); int C = dist[a]; int D = dist[b]; int res = min(C - A , D - B); if (res < 0) res = -1; cout << res << endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...