# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
422712 |
2021-06-10T11:00:08 Z |
SSRS |
Sky Walking (IOI19_walk) |
C++14 |
|
4000 ms |
482996 KB |
#include <bits/stdc++.h>
using namespace std;
long long min_distance(vector<int> x, vector<int> h, vector<int> l, vector<int> r, vector<int> y, int s, int g){
int n = x.size();
int m = y.size();
vector<tuple<int, int, int>> T;
for (int i = 0; i < n; i++){
T.push_back(make_tuple(h[i], 1, i));
}
for (int i = 0; i < m; i++){
T.push_back(make_tuple(y[i], 0, i));
}
sort(T.begin(), T.end(), greater<tuple<int, int, int>>());
vector<vector<int>> id(m);
set<int> st;
for (int i = 0; i < n + m; i++){
int t = get<1>(T[i]);
int p = get<2>(T[i]);
if (t == 0){
auto itr = st.lower_bound(l[p]);
while (true){
id[p].push_back(*itr);
if (*itr == r[p]){
break;
}
itr++;
}
}
if (t == 1){
st.insert(p);
}
}
vector<vector<int>> h2(n);
for (int i = 0; i < n; i++){
h2[i].push_back(0);
}
for (int i = 0; i < m; i++){
for (int j : id[i]){
h2[j].push_back(y[i]);
}
}
for (int i = 0; i < n; i++){
sort(h2[i].begin(), h2[i].end());
h2[i].erase(unique(h2[i].begin(), h2[i].end()), h2[i].end());
}
int V = 0;
vector<vector<int>> id2(n);
for (int i = 0; i < n; i++){
int cnt = h2[i].size();
id2[i] = vector<int>(cnt);
for (int j = 0; j < cnt; j++){
id2[i][j] = V;
V++;
}
}
vector<vector<pair<int, int>>> E(V);
for (int i = 0; i < n; i++){
int cnt = h2[i].size();
for (int j = 0; j < cnt - 1; j++){
int v = id2[i][j];
int w = id2[i][j + 1];
int d = h2[i][j + 1] - h2[i][j];
E[v].push_back(make_pair(d, w));
E[w].push_back(make_pair(d, v));
}
}
for (int i = 0; i < m; i++){
int cnt = id[i].size();
vector<int> t(cnt);
for (int j = 0; j < cnt; j++){
int p = lower_bound(h2[id[i][j]].begin(), h2[id[i][j]].end(), y[i]) - h2[id[i][j]].begin();
t[j] = id2[id[i][j]][p];
}
for (int j = 0; j < cnt - 1; j++){
int v = t[j];
int w = t[j + 1];
int d = x[id[i][j + 1]] - x[id[i][j]];
E[v].push_back(make_pair(d, w));
E[w].push_back(make_pair(d, v));
}
}
int s2 = id2[s][0];
int g2 = id2[g][0];
vector<long long> d(V, -1);
priority_queue<pair<long long, int>, vector<pair<long long, int>>, greater<pair<long long, int>>> pq;
pq.push(make_pair(0, s2));
while (!pq.empty()){
long long dd = pq.top().first;
int v = pq.top().second;
pq.pop();
if (d[v] == -1){
d[v] = dd;
for (auto P : E[v]){
int w = P.second;
if (d[w] == -1){
pq.push(make_pair(dd + P.first, w));
}
}
}
}
return d[g2];
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
292 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
292 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
1 ms |
204 KB |
Output is correct |
10 |
Correct |
1 ms |
332 KB |
Output is correct |
11 |
Correct |
1 ms |
204 KB |
Output is correct |
12 |
Correct |
1 ms |
204 KB |
Output is correct |
13 |
Correct |
1 ms |
204 KB |
Output is correct |
14 |
Correct |
1 ms |
204 KB |
Output is correct |
15 |
Correct |
1 ms |
204 KB |
Output is correct |
16 |
Correct |
1 ms |
204 KB |
Output is correct |
17 |
Correct |
2 ms |
324 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1041 ms |
83960 KB |
Output is correct |
4 |
Correct |
1084 ms |
105324 KB |
Output is correct |
5 |
Correct |
701 ms |
92708 KB |
Output is correct |
6 |
Correct |
623 ms |
84884 KB |
Output is correct |
7 |
Correct |
702 ms |
92880 KB |
Output is correct |
8 |
Correct |
1356 ms |
104692 KB |
Output is correct |
9 |
Correct |
857 ms |
90216 KB |
Output is correct |
10 |
Correct |
1469 ms |
137044 KB |
Output is correct |
11 |
Correct |
610 ms |
54960 KB |
Output is correct |
12 |
Correct |
431 ms |
54552 KB |
Output is correct |
13 |
Correct |
1243 ms |
123152 KB |
Output is correct |
14 |
Correct |
353 ms |
51696 KB |
Output is correct |
15 |
Correct |
408 ms |
54456 KB |
Output is correct |
16 |
Correct |
367 ms |
52188 KB |
Output is correct |
17 |
Correct |
344 ms |
50596 KB |
Output is correct |
18 |
Correct |
371 ms |
56164 KB |
Output is correct |
19 |
Correct |
10 ms |
2844 KB |
Output is correct |
20 |
Correct |
120 ms |
25476 KB |
Output is correct |
21 |
Correct |
306 ms |
46664 KB |
Output is correct |
22 |
Correct |
326 ms |
54312 KB |
Output is correct |
23 |
Correct |
464 ms |
62156 KB |
Output is correct |
24 |
Correct |
354 ms |
52428 KB |
Output is correct |
25 |
Correct |
332 ms |
49840 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
98 ms |
13756 KB |
Output is correct |
2 |
Execution timed out |
4112 ms |
482996 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
98 ms |
13756 KB |
Output is correct |
2 |
Execution timed out |
4112 ms |
482996 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
292 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
292 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
1 ms |
204 KB |
Output is correct |
10 |
Correct |
1 ms |
332 KB |
Output is correct |
11 |
Correct |
1 ms |
204 KB |
Output is correct |
12 |
Correct |
1 ms |
204 KB |
Output is correct |
13 |
Correct |
1 ms |
204 KB |
Output is correct |
14 |
Correct |
1 ms |
204 KB |
Output is correct |
15 |
Correct |
1 ms |
204 KB |
Output is correct |
16 |
Correct |
1 ms |
204 KB |
Output is correct |
17 |
Correct |
2 ms |
324 KB |
Output is correct |
18 |
Correct |
1 ms |
204 KB |
Output is correct |
19 |
Correct |
1 ms |
204 KB |
Output is correct |
20 |
Correct |
1041 ms |
83960 KB |
Output is correct |
21 |
Correct |
1084 ms |
105324 KB |
Output is correct |
22 |
Correct |
701 ms |
92708 KB |
Output is correct |
23 |
Correct |
623 ms |
84884 KB |
Output is correct |
24 |
Correct |
702 ms |
92880 KB |
Output is correct |
25 |
Correct |
1356 ms |
104692 KB |
Output is correct |
26 |
Correct |
857 ms |
90216 KB |
Output is correct |
27 |
Correct |
1469 ms |
137044 KB |
Output is correct |
28 |
Correct |
610 ms |
54960 KB |
Output is correct |
29 |
Correct |
431 ms |
54552 KB |
Output is correct |
30 |
Correct |
1243 ms |
123152 KB |
Output is correct |
31 |
Correct |
353 ms |
51696 KB |
Output is correct |
32 |
Correct |
408 ms |
54456 KB |
Output is correct |
33 |
Correct |
367 ms |
52188 KB |
Output is correct |
34 |
Correct |
344 ms |
50596 KB |
Output is correct |
35 |
Correct |
371 ms |
56164 KB |
Output is correct |
36 |
Correct |
10 ms |
2844 KB |
Output is correct |
37 |
Correct |
120 ms |
25476 KB |
Output is correct |
38 |
Correct |
306 ms |
46664 KB |
Output is correct |
39 |
Correct |
326 ms |
54312 KB |
Output is correct |
40 |
Correct |
464 ms |
62156 KB |
Output is correct |
41 |
Correct |
354 ms |
52428 KB |
Output is correct |
42 |
Correct |
332 ms |
49840 KB |
Output is correct |
43 |
Correct |
98 ms |
13756 KB |
Output is correct |
44 |
Execution timed out |
4112 ms |
482996 KB |
Time limit exceeded |
45 |
Halted |
0 ms |
0 KB |
- |