# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
416313 |
2021-06-02T10:12:17 Z |
idk321 |
Sky Walking (IOI19_walk) |
C++17 |
|
4000 ms |
899244 KB |
#include "walk.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int M = 2000005;
const int N = 100005;
const ll INF = 2000000000000000000LL;
vector<array<int, 2>> adj[M];
vector<array<int, 2>> isAt[N];
int cnode = 0;
///usr/include/c++/10/bits/stl_heap.h|209|error: ‘bool Comparator::operator()(const std::__debug::array<long long int, 2>&, const std::__debug::array<long long int, 2>&) const’ is private within this context|
struct Comparator
{
bool operator() (const array<ll, 2>& ar1, const array<ll, 2>& ar2) const
{
return tie(ar1[1], ar1[0]) > tie(ar2[1], ar2[0]);
}
};
long long min_distance(std::vector<int> x, std::vector<int> h, std::vector<int> l, std::vector<int> r, std::vector<int> y, int s, int g) {
int snode = -1;
int gnode = -1;
for (int i = 0; i < x.size(); i++)
{
isAt[i].push_back({cnode, 0});
if (i == s)
{
snode = cnode;
}
if (i == g)
{
gnode = cnode;
}
cnode++;
}
for (int i = 0; i < l.size(); i++)
{
int prev = -1;
for (int j = l[i]; j <= r[i]; j++)
{
if (h[j] >= y[i])
{
for (auto ar : isAt[j])
{
adj[cnode].push_back({ar[0], abs(ar[1] - y[i])});
adj[ar[0]].push_back({cnode, abs(ar[1] - y[i])});
}
isAt[j].push_back({cnode, y[i]});
if (prev != -1)
{
adj[cnode].push_back({cnode - 1, x[j] - x[prev]});
adj[cnode - 1].push_back({cnode, x[j] - x[prev]});
}
prev = j;
cnode++;
}
}
}
priority_queue<array<ll, 2>, vector<array<ll, 2>>, Comparator> pq;
pq.push({snode, 0});
vector<ll> dist(M, INF);
while (!pq.empty())
{
auto cur = pq.top();
pq.pop();
if (dist[cur[0]] != INF) continue;
dist[cur[0]] = cur[1];
for (auto next : adj[cur[0]])
{
if (dist[next[0]] == INF)
{
pq.push({next[0], next[1] + cur[1]});
}
}
}
if (dist[gnode] == INF) return -1;
return dist[gnode];
}
Compilation message
walk.cpp: In function 'long long int min_distance(std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>, int, int)':
walk.cpp:32:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
32 | for (int i = 0; i < x.size(); i++)
| ~~^~~~~~~~~~
walk.cpp:46:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
46 | for (int i = 0; i < l.size(); i++)
| ~~^~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
37 ms |
65228 KB |
Output is correct |
2 |
Correct |
36 ms |
65144 KB |
Output is correct |
3 |
Correct |
37 ms |
65220 KB |
Output is correct |
4 |
Correct |
39 ms |
65212 KB |
Output is correct |
5 |
Correct |
37 ms |
65416 KB |
Output is correct |
6 |
Correct |
38 ms |
65392 KB |
Output is correct |
7 |
Correct |
37 ms |
65360 KB |
Output is correct |
8 |
Correct |
38 ms |
65304 KB |
Output is correct |
9 |
Correct |
37 ms |
65232 KB |
Output is correct |
10 |
Correct |
41 ms |
65608 KB |
Output is correct |
11 |
Correct |
37 ms |
65260 KB |
Output is correct |
12 |
Correct |
37 ms |
65236 KB |
Output is correct |
13 |
Correct |
38 ms |
65280 KB |
Output is correct |
14 |
Correct |
40 ms |
65192 KB |
Output is correct |
15 |
Correct |
38 ms |
65228 KB |
Output is correct |
16 |
Correct |
40 ms |
65216 KB |
Output is correct |
17 |
Correct |
40 ms |
65612 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
37 ms |
65216 KB |
Output is correct |
2 |
Correct |
38 ms |
65172 KB |
Output is correct |
3 |
Execution timed out |
4040 ms |
562580 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
271 ms |
86304 KB |
Output is correct |
2 |
Execution timed out |
4085 ms |
899244 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
271 ms |
86304 KB |
Output is correct |
2 |
Execution timed out |
4085 ms |
899244 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
37 ms |
65228 KB |
Output is correct |
2 |
Correct |
36 ms |
65144 KB |
Output is correct |
3 |
Correct |
37 ms |
65220 KB |
Output is correct |
4 |
Correct |
39 ms |
65212 KB |
Output is correct |
5 |
Correct |
37 ms |
65416 KB |
Output is correct |
6 |
Correct |
38 ms |
65392 KB |
Output is correct |
7 |
Correct |
37 ms |
65360 KB |
Output is correct |
8 |
Correct |
38 ms |
65304 KB |
Output is correct |
9 |
Correct |
37 ms |
65232 KB |
Output is correct |
10 |
Correct |
41 ms |
65608 KB |
Output is correct |
11 |
Correct |
37 ms |
65260 KB |
Output is correct |
12 |
Correct |
37 ms |
65236 KB |
Output is correct |
13 |
Correct |
38 ms |
65280 KB |
Output is correct |
14 |
Correct |
40 ms |
65192 KB |
Output is correct |
15 |
Correct |
38 ms |
65228 KB |
Output is correct |
16 |
Correct |
40 ms |
65216 KB |
Output is correct |
17 |
Correct |
40 ms |
65612 KB |
Output is correct |
18 |
Correct |
37 ms |
65216 KB |
Output is correct |
19 |
Correct |
38 ms |
65172 KB |
Output is correct |
20 |
Execution timed out |
4040 ms |
562580 KB |
Time limit exceeded |
21 |
Halted |
0 ms |
0 KB |
- |