# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
417260 |
2021-06-03T14:03:08 Z |
Mlxa |
Sky Walking (IOI19_walk) |
C++14 |
|
4000 ms |
861780 KB |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define all(x) x.begin(), x.end()
#define mp make_pair
#define mt make_tuple
#define x first
#define y second
#include "walk.h"
namespace my {
const int N = 2e6 + 10;
map<pair<int, int>, int> was;
int id(int x, int y) {
auto p = mp(x, y);
if (was.count(p)) {
return was[p];
} else {
int v = (int)was.size();
assert(v < N);
return was[p] = v;
}
}
vector<pair<int, int>> g[N];
set<int> ys[N];
void edge(int v, int u, int w) {
g[v].emplace_back(u, w);
g[u].emplace_back(v, w);
}
using T = pair<ll, int>;
const ll INF = 1e18;
priority_queue<T, vector<T>, greater<T>> q;
ll dst[N];
}
ll min_distance(vector<int> x, vector<int> h, vector<int> l, vector<int> r, vector<int> y, int st, int fi) {
using namespace my;
for (int i = 0; i < (int)y.size(); ++i) {
int lst = l[i];
for (int j = l[i] + 1; j <= r[i]; ++j) {
if (h[j] < y[i]) {
continue;
}
edge(id(x[lst], y[i]), id(x[j], y[i]), abs(x[lst] - x[j]));
lst = j;
}
for (int j = l[i]; j <= r[i]; ++j) {
if (h[j] >= y[i]) {
ys[j].insert(y[i]);
}
}
}
for (int i = 0; i < (int)x.size(); ++i) {
int ly = 0, lv = id(x[i], 0);
for (int cur : ys[i]) {
int ver = id(x[i], cur);
edge(lv, ver, abs(cur - ly));
ly = cur, lv = ver;
}
}
int from = id(x[st], 0), to = id(x[fi], 0);
fill_n(dst, N, INF);
dst[from] = 0;
q.emplace(dst[from], from);
while (q.size()) {
ll d, w;
int v, u;
tie(d, v) = q.top(); q.pop();
if (d != dst[v]) {
continue;
}
for (auto e : g[v]) {
u = e.x, w = e.y;
if (dst[u] > dst[v] + w) {
dst[u] = dst[v] + w;
q.emplace(dst[u], u);
}
}
}
if (dst[to] > INF / 2) {
return -1;
}
return dst[to];
}
#ifdef LC
#include "grader.cpp"
#endif
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
93 ms |
156736 KB |
Output is correct |
2 |
Correct |
96 ms |
156724 KB |
Output is correct |
3 |
Correct |
92 ms |
156756 KB |
Output is correct |
4 |
Correct |
98 ms |
156768 KB |
Output is correct |
5 |
Correct |
109 ms |
156912 KB |
Output is correct |
6 |
Correct |
99 ms |
156984 KB |
Output is correct |
7 |
Correct |
94 ms |
156868 KB |
Output is correct |
8 |
Correct |
97 ms |
156872 KB |
Output is correct |
9 |
Correct |
96 ms |
156808 KB |
Output is correct |
10 |
Correct |
98 ms |
156992 KB |
Output is correct |
11 |
Correct |
97 ms |
156880 KB |
Output is correct |
12 |
Correct |
97 ms |
156824 KB |
Output is correct |
13 |
Correct |
97 ms |
156740 KB |
Output is correct |
14 |
Correct |
99 ms |
156760 KB |
Output is correct |
15 |
Correct |
102 ms |
156848 KB |
Output is correct |
16 |
Correct |
101 ms |
156844 KB |
Output is correct |
17 |
Correct |
97 ms |
156996 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
98 ms |
156740 KB |
Output is correct |
2 |
Correct |
99 ms |
156740 KB |
Output is correct |
3 |
Correct |
2040 ms |
288124 KB |
Output is correct |
4 |
Correct |
1671 ms |
296124 KB |
Output is correct |
5 |
Correct |
1298 ms |
277140 KB |
Output is correct |
6 |
Correct |
2431 ms |
262188 KB |
Output is correct |
7 |
Correct |
1411 ms |
277112 KB |
Output is correct |
8 |
Correct |
2699 ms |
325152 KB |
Output is correct |
9 |
Correct |
1428 ms |
275476 KB |
Output is correct |
10 |
Correct |
2284 ms |
352648 KB |
Output is correct |
11 |
Correct |
1016 ms |
225608 KB |
Output is correct |
12 |
Correct |
550 ms |
200904 KB |
Output is correct |
13 |
Correct |
1962 ms |
328384 KB |
Output is correct |
14 |
Execution timed out |
4070 ms |
162628 KB |
Time limit exceeded |
15 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
261 ms |
169344 KB |
Output is correct |
2 |
Runtime error |
3367 ms |
861780 KB |
Execution killed with signal 6 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
261 ms |
169344 KB |
Output is correct |
2 |
Runtime error |
3367 ms |
861780 KB |
Execution killed with signal 6 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
93 ms |
156736 KB |
Output is correct |
2 |
Correct |
96 ms |
156724 KB |
Output is correct |
3 |
Correct |
92 ms |
156756 KB |
Output is correct |
4 |
Correct |
98 ms |
156768 KB |
Output is correct |
5 |
Correct |
109 ms |
156912 KB |
Output is correct |
6 |
Correct |
99 ms |
156984 KB |
Output is correct |
7 |
Correct |
94 ms |
156868 KB |
Output is correct |
8 |
Correct |
97 ms |
156872 KB |
Output is correct |
9 |
Correct |
96 ms |
156808 KB |
Output is correct |
10 |
Correct |
98 ms |
156992 KB |
Output is correct |
11 |
Correct |
97 ms |
156880 KB |
Output is correct |
12 |
Correct |
97 ms |
156824 KB |
Output is correct |
13 |
Correct |
97 ms |
156740 KB |
Output is correct |
14 |
Correct |
99 ms |
156760 KB |
Output is correct |
15 |
Correct |
102 ms |
156848 KB |
Output is correct |
16 |
Correct |
101 ms |
156844 KB |
Output is correct |
17 |
Correct |
97 ms |
156996 KB |
Output is correct |
18 |
Correct |
98 ms |
156740 KB |
Output is correct |
19 |
Correct |
99 ms |
156740 KB |
Output is correct |
20 |
Correct |
2040 ms |
288124 KB |
Output is correct |
21 |
Correct |
1671 ms |
296124 KB |
Output is correct |
22 |
Correct |
1298 ms |
277140 KB |
Output is correct |
23 |
Correct |
2431 ms |
262188 KB |
Output is correct |
24 |
Correct |
1411 ms |
277112 KB |
Output is correct |
25 |
Correct |
2699 ms |
325152 KB |
Output is correct |
26 |
Correct |
1428 ms |
275476 KB |
Output is correct |
27 |
Correct |
2284 ms |
352648 KB |
Output is correct |
28 |
Correct |
1016 ms |
225608 KB |
Output is correct |
29 |
Correct |
550 ms |
200904 KB |
Output is correct |
30 |
Correct |
1962 ms |
328384 KB |
Output is correct |
31 |
Execution timed out |
4070 ms |
162628 KB |
Time limit exceeded |
32 |
Halted |
0 ms |
0 KB |
- |