#include <bits/stdc++.h>
#include "wombats.h"
/// #pragma GCC optimize ("Ofast")
/// #pragma GCC target ("avx2")
/// #pragma GCC optimize("unroll-loops")
using namespace std;
using ll = long long;
using ii = pair<ll, ll>;
using vi = vector<int>;
#define ff first
#define ss second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define lb lower_bound
const int oo = 1000 * 1000 * 1000 + 7;
int R, C, H[5000][200], K[5000][200];
void init(int r, int c, int h[5000][200], int v[5000][200]) {
R = r, C = c;
for(int l = 0; l < R; l++)
for(int i = 0; i < C; i++)
H[l][i] = h[l][i],
K[l][i] = v[l][i];
}
void changeH(int P, int Q, int W) { H[P][Q] = W; }
void changeV(int P, int Q, int W) { K[P][Q] = W; }
using pi = pair<int, pair<int, int>>;
int escape(int V1, int V2) {
priority_queue<pi, vector<pi>, greater<pi>> pq;
pq.push({0, {0, V1}}); vector<vector<int>> D;
D = vector<vector<int>> (R, vector<int>(C, oo));
D[0][V1] = 0;
while(!pq.empty()) {
int U = pq.top().ss.ff, V = pq.top().ss.ss;
int W = pq.top().ff; pq.pop();
if(W != D[U][V]) continue;
if(V < C - 1) {
if(D[U][V + 1] > D[U][V] + H[U][V]) {
D[U][V + 1] = D[U][V] + H[U][V];
pq.push({D[U][V + 1], {U, V + 1}});
}
}
if(V > 0) {
if(D[U][V - 1] > D[U][V] + H[U][V - 1]) {
D[U][V - 1] = D[U][V] + H[U][V - 1];
pq.push({D[U][V - 1], {U, V - 1}});
}
}
if(U < R - 1) {
if(D[U + 1][V] > D[U][V] + K[U][V]) {
D[U + 1][V] = D[U][V] + K[U][V];
pq.push({D[U + 1][V], {U + 1, V}});
}
}
}
return D[R - 1][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 |
153 ms |
12368 KB |
Output is correct |
2 |
Correct |
178 ms |
12356 KB |
Output is correct |
3 |
Execution timed out |
20023 ms |
13428 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
308 KB |
Output is correct |
3 |
Correct |
1 ms |
304 KB |
Output is correct |
4 |
Correct |
23 ms |
340 KB |
Output is correct |
5 |
Correct |
8 ms |
400 KB |
Output is correct |
6 |
Correct |
10 ms |
340 KB |
Output is correct |
7 |
Correct |
23 ms |
340 KB |
Output is correct |
8 |
Correct |
14 ms |
340 KB |
Output is correct |
9 |
Correct |
15 ms |
400 KB |
Output is correct |
10 |
Correct |
14 ms |
400 KB |
Output is correct |
11 |
Correct |
7058 ms |
2744 KB |
Output is correct |
12 |
Correct |
19 ms |
404 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
121 ms |
724 KB |
Output is correct |
2 |
Correct |
222 ms |
972 KB |
Output is correct |
3 |
Correct |
147 ms |
752 KB |
Output is correct |
4 |
Correct |
127 ms |
760 KB |
Output is correct |
5 |
Correct |
120 ms |
844 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
308 KB |
Output is correct |
9 |
Correct |
192 ms |
800 KB |
Output is correct |
10 |
Correct |
1 ms |
304 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
656 ms |
16332 KB |
Output is correct |
2 |
Correct |
1300 ms |
16272 KB |
Output is correct |
3 |
Correct |
592 ms |
16288 KB |
Output is correct |
4 |
Execution timed out |
20034 ms |
16952 KB |
Time limit exceeded |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
139 ms |
752 KB |
Output is correct |
2 |
Correct |
210 ms |
920 KB |
Output is correct |
3 |
Correct |
131 ms |
756 KB |
Output is correct |
4 |
Correct |
136 ms |
752 KB |
Output is correct |
5 |
Correct |
141 ms |
724 KB |
Output is correct |
6 |
Correct |
623 ms |
16292 KB |
Output is correct |
7 |
Correct |
1272 ms |
16280 KB |
Output is correct |
8 |
Correct |
614 ms |
16408 KB |
Output is correct |
9 |
Execution timed out |
20097 ms |
17060 KB |
Time limit exceeded |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
130 ms |
752 KB |
Output is correct |
2 |
Correct |
208 ms |
920 KB |
Output is correct |
3 |
Correct |
119 ms |
760 KB |
Output is correct |
4 |
Correct |
126 ms |
756 KB |
Output is correct |
5 |
Correct |
145 ms |
756 KB |
Output is correct |
6 |
Correct |
616 ms |
16284 KB |
Output is correct |
7 |
Correct |
1300 ms |
16404 KB |
Output is correct |
8 |
Correct |
604 ms |
16340 KB |
Output is correct |
9 |
Execution timed out |
20040 ms |
16816 KB |
Time limit exceeded |
10 |
Halted |
0 ms |
0 KB |
- |