Submission #254064

#TimeUsernameProblemLanguageResultExecution timeMemory
254064ErkhemkhuuSky Walking (IOI19_walk)C++17
0 / 100
58 ms8056 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define mp make_pair #define F first #define S second const ll N = 105; typedef vector <int> vi; bool vis[N][N]; vector <pair <int, int> > adj[N][N]; int min_distance(vi x, vi h, vi l, vi r, vi y, int s, int g) { int n, m, i, j; n = x.size(); m = l.size(); for(i = 0; i < n; i++) { for(j = h[i]; j >= 1; j--) { adj[x[i]][j].pb(mp(x[i], j - 1)); adj[x[i]][j - 1].pb(mp(x[i], j)); } } for(i = 0; i < m; i++) { for(j = x[l[i]] + 1; j <= x[r[i]]; j++) { adj[j][y[i]].pb(mp(j - 1, y[i])); adj[j - 1][y[i]].pb(mp(j, y[i])); } } queue <pair <pair <int, int>, int> > q; q.push(mp(mp(x[s], 0), 0)); while(!q.empty()) { auto v = q.front(); q.pop(); if(v.F.F == x[g] && !v.F.S) return v.S; if(vis[v.F.F][v.F.S]) continue; vis[v.F.F][v.F.S] = true; for(auto &to: adj[v.F.F][v.F.S]) { if(vis[to.F][to.S]) continue; q.push(mp(mp(to.F, to.S), v.S + 1)); } } return -1; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...