# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
808967 |
2023-08-05T13:00:55 Z |
jakobrs |
Wombats (IOI13_wombats) |
C++17 |
|
20000 ms |
17736 KB |
#include <algorithm>
#include <numeric>
#include <queue>
#include <vector>
#ifndef EVAL
#include <iostream>
#endif
#include "wombats.h"
#define entire(a) std::begin((a)), std::end((a))
std::vector<std::vector<int>> h, v;
int r, c;
void init(int R, int C, int H[5000][200], int V[5000][200]) {
h.reserve(R);
v.reserve(R);
for (int i = 0; i < R; i++) {
h.emplace_back(entire(H[i]));
v.emplace_back(entire(V[i]));
}
r = R;
c = C;
}
void changeH(int P, int Q, int W) { h[P][Q] = W; }
void changeV(int P, int Q, int W) { v[P][Q] = W; }
int escape(int V1, int V2) {
std::vector<int> dist(c, 0);
dist[V1] = 0;
for (int i = V1 + 1; i < c; i++) {
dist[i] = dist[i - 1] + h[0][i - 1];
}
for (int i = V1 - 1; i >= 0; i--) {
dist[i] = dist[i + 1] + h[0][i];
}
std::priority_queue<std::pair<int, int>> pq;
for (int i = 0; i + 1 < r; i++) {
// phase 1: process vertical segments
for (int j = 0; j < c; j++) {
dist[j] += v[i][j];
}
// phase 2: process horizontal segments
while (!pq.empty()) pq.pop(); // whyy is there no pq.clear();
for (int j = 0; j < c; j++) {
pq.push({-dist[j], j});
}
while (!pq.empty()) {
auto [d, j] = pq.top();
pq.pop();
d = -d;
if (d > dist[j]) continue;
if (j > 0 && dist[j - 1] > d + h[i + 1][j - 1]) {
dist[j - 1] = d + h[i + 1][j - 1];
pq.push({-dist[j - 1], j - 1});
}
if (j + 1 < c && dist[j + 1] > d + h[i + 1][j]) {
dist[j + 1] = d + h[i + 1][j];
pq.push({-dist[j + 1], j + 1});
}
}
}
return dist[V2];
}
Compilation message
grader.c: In function 'int main()':
grader.c:15:6: warning: variable 'res' set but not used [-Wunused-but-set-variable]
15 | int res;
| ^~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
35 ms |
12372 KB |
Output is correct |
2 |
Correct |
35 ms |
12372 KB |
Output is correct |
3 |
Correct |
11636 ms |
13940 KB |
Output is correct |
4 |
Correct |
35 ms |
12420 KB |
Output is correct |
5 |
Correct |
36 ms |
12372 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
8 ms |
352 KB |
Output is correct |
5 |
Correct |
3 ms |
340 KB |
Output is correct |
6 |
Correct |
4 ms |
340 KB |
Output is correct |
7 |
Correct |
7 ms |
340 KB |
Output is correct |
8 |
Correct |
7 ms |
340 KB |
Output is correct |
9 |
Correct |
9 ms |
364 KB |
Output is correct |
10 |
Correct |
8 ms |
340 KB |
Output is correct |
11 |
Correct |
4501 ms |
2724 KB |
Output is correct |
12 |
Correct |
7 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
93 ms |
608 KB |
Output is correct |
2 |
Correct |
56 ms |
672 KB |
Output is correct |
3 |
Correct |
94 ms |
688 KB |
Output is correct |
4 |
Correct |
93 ms |
688 KB |
Output is correct |
5 |
Correct |
91 ms |
688 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
66 ms |
680 KB |
Output is correct |
10 |
Correct |
0 ms |
296 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
212 ms |
16296 KB |
Output is correct |
2 |
Correct |
223 ms |
16376 KB |
Output is correct |
3 |
Correct |
220 ms |
16460 KB |
Output is correct |
4 |
Execution timed out |
20075 ms |
17688 KB |
Time limit exceeded |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
94 ms |
608 KB |
Output is correct |
2 |
Correct |
54 ms |
672 KB |
Output is correct |
3 |
Correct |
94 ms |
688 KB |
Output is correct |
4 |
Correct |
97 ms |
692 KB |
Output is correct |
5 |
Correct |
91 ms |
688 KB |
Output is correct |
6 |
Correct |
210 ms |
16388 KB |
Output is correct |
7 |
Correct |
222 ms |
16376 KB |
Output is correct |
8 |
Correct |
214 ms |
16396 KB |
Output is correct |
9 |
Execution timed out |
20048 ms |
17692 KB |
Time limit exceeded |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
92 ms |
604 KB |
Output is correct |
2 |
Correct |
56 ms |
672 KB |
Output is correct |
3 |
Correct |
104 ms |
692 KB |
Output is correct |
4 |
Correct |
101 ms |
688 KB |
Output is correct |
5 |
Correct |
92 ms |
692 KB |
Output is correct |
6 |
Correct |
211 ms |
16388 KB |
Output is correct |
7 |
Correct |
222 ms |
16376 KB |
Output is correct |
8 |
Correct |
210 ms |
16340 KB |
Output is correct |
9 |
Execution timed out |
20008 ms |
17736 KB |
Time limit exceeded |
10 |
Halted |
0 ms |
0 KB |
- |