# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1053301 |
2024-08-11T10:23:02 Z |
Tob |
Sky Walking (IOI19_walk) |
C++14 |
|
4000 ms |
360280 KB |
#include <bits/stdc++.h>
#include "walk.h"
#define F first
#define S second
#define pb push_back
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll;
typedef pair <int, int> pii;
typedef vector <int> vi;
const int N = 1e5 + 7, C = 12e5 + 7;
const ll inf = 1e18;
int n, m, cnt;
ll g[N], h[N], dis[C];
vector <int> ad[N];
vector <pii> adj[C];
void Edge(int x, int y, int val) {
adj[x].pb({y, val});
adj[y].pb({x, val});
}
ll E(ll x, ll y) {return (x << 32)+y;}
ll min_distance(vi x, vi h, vi l, vi r, vi y, int sta, int en) {
n = x.size(); m = l.size();
map <int, vector <int> > ma;
unordered_map <ll, int> wh;
for (int i = 0; i < n; i++) ma[h[i]].pb(i);
for (int i = 0; i < m; i++) ma[y[i]].pb(i+n);
set <int> st;
cnt = n;
while (!ma.empty()) {
auto it = *(--ma.end());
for (auto xx : it.S) {
if (xx < n) st.insert(xx);
else {
xx -= n;
auto p = st.lower_bound(l[xx]);
int la = -1;
while (p != st.end() && *p <= r[xx]) {
ad[*p].pb(it.F);
int tmp = wh[E(*p, it.F)];
if (!tmp) {
tmp = cnt;
wh[E(*p, it.F)] = cnt++;
}
if (la != -1) Edge(wh[E(la, it.F)], tmp, x[*p]-x[la]);
la = *p;
++p;
}
}
}
ma.erase(--ma.end());
}
for (int i = 0; i < n; i++) {
sort(all(ad[i]));
if (ad[i].empty()) continue;
Edge(i, wh[E(i, ad[i][0])], ad[i][0]);
for (int j = 1; j < ad[i].size(); j++) Edge(wh[E(i, ad[i][j-1])], wh[E(i, ad[i][j])], ad[i][j]-ad[i][j-1]);
}
set <pii> s;
s.insert({0, sta});
for (int i = 0; i < cnt; i++) dis[i] = inf;
dis[sta] = 0;
while (!s.empty()) {
auto p = s.begin();
int xx = p -> S;
s.erase(p);
for (auto y : adj[xx]) {
if (dis[xx] + y.S < dis[y.F]) {
if (dis[y.F] != inf) s.erase({dis[y.F], y.F});
dis[y.F] = dis[xx] + y.S;
s.insert({dis[y.F], y.F});
}
}
}
return (dis[en] >= inf) ? -1 : dis[en];
}
Compilation message
walk.cpp: In function 'll min_distance(vi, vi, vi, vi, vi, int, int)':
walk.cpp:67:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
67 | for (int j = 1; j < ad[i].size(); j++) Edge(wh[E(i, ad[i][j-1])], wh[E(i, ad[i][j])], ad[i][j]-ad[i][j-1]);
| ~~^~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
31324 KB |
Output is correct |
2 |
Correct |
4 ms |
31324 KB |
Output is correct |
3 |
Correct |
4 ms |
31324 KB |
Output is correct |
4 |
Correct |
4 ms |
31324 KB |
Output is correct |
5 |
Correct |
5 ms |
31324 KB |
Output is correct |
6 |
Correct |
6 ms |
31324 KB |
Output is correct |
7 |
Correct |
4 ms |
31324 KB |
Output is correct |
8 |
Correct |
4 ms |
31336 KB |
Output is correct |
9 |
Correct |
4 ms |
31324 KB |
Output is correct |
10 |
Correct |
4 ms |
31324 KB |
Output is correct |
11 |
Correct |
5 ms |
31348 KB |
Output is correct |
12 |
Correct |
5 ms |
31320 KB |
Output is correct |
13 |
Correct |
4 ms |
31324 KB |
Output is correct |
14 |
Correct |
4 ms |
31324 KB |
Output is correct |
15 |
Correct |
4 ms |
31324 KB |
Output is correct |
16 |
Correct |
4 ms |
31320 KB |
Output is correct |
17 |
Correct |
4 ms |
31324 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
31324 KB |
Output is correct |
2 |
Correct |
4 ms |
31320 KB |
Output is correct |
3 |
Correct |
744 ms |
123632 KB |
Output is correct |
4 |
Execution timed out |
4070 ms |
129616 KB |
Time limit exceeded |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
50 ms |
44060 KB |
Output is correct |
2 |
Runtime error |
415 ms |
360280 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
50 ms |
44060 KB |
Output is correct |
2 |
Runtime error |
415 ms |
360280 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
31324 KB |
Output is correct |
2 |
Correct |
4 ms |
31324 KB |
Output is correct |
3 |
Correct |
4 ms |
31324 KB |
Output is correct |
4 |
Correct |
4 ms |
31324 KB |
Output is correct |
5 |
Correct |
5 ms |
31324 KB |
Output is correct |
6 |
Correct |
6 ms |
31324 KB |
Output is correct |
7 |
Correct |
4 ms |
31324 KB |
Output is correct |
8 |
Correct |
4 ms |
31336 KB |
Output is correct |
9 |
Correct |
4 ms |
31324 KB |
Output is correct |
10 |
Correct |
4 ms |
31324 KB |
Output is correct |
11 |
Correct |
5 ms |
31348 KB |
Output is correct |
12 |
Correct |
5 ms |
31320 KB |
Output is correct |
13 |
Correct |
4 ms |
31324 KB |
Output is correct |
14 |
Correct |
4 ms |
31324 KB |
Output is correct |
15 |
Correct |
4 ms |
31324 KB |
Output is correct |
16 |
Correct |
4 ms |
31320 KB |
Output is correct |
17 |
Correct |
4 ms |
31324 KB |
Output is correct |
18 |
Correct |
4 ms |
31324 KB |
Output is correct |
19 |
Correct |
4 ms |
31320 KB |
Output is correct |
20 |
Correct |
744 ms |
123632 KB |
Output is correct |
21 |
Execution timed out |
4070 ms |
129616 KB |
Time limit exceeded |
22 |
Halted |
0 ms |
0 KB |
- |