#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>;
using pi = pair<int, pair<int, 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], DP[100][100];
void precomputation(int i) {
priority_queue<pi, vector<pi>, greater<pi>> pq;
pq.push({0, {0, i}}); vector<vector<int>> D;
D = vector<vector<int>> (R, vector<int>(C, oo));
D[0][i] = 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}});
}
}
}
for(int l = 0; l < C; l++)
DP[i][l] = D[R - 1][l];
}
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];
for(int l = 0; l < C; l++) precomputation(l);
}
void changeH(int P, int Q, int W) {
H[P][Q] = W;
for(int l = 0; l < C; l++) precomputation(l);
}
void changeV(int P, int Q, int W) {
K[P][Q] = W;
for(int l = 0; l < C; l++) precomputation(l);
}
int escape(int V1, int V2) {
return DP[V1][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;
| ^~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
181 ms |
12328 KB |
Output is correct |
2 |
Correct |
160 ms |
12380 KB |
Output is correct |
3 |
Correct |
236 ms |
13784 KB |
Output is correct |
4 |
Correct |
163 ms |
12480 KB |
Output is correct |
5 |
Correct |
170 ms |
12316 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
2 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
2 ms |
340 KB |
Output is correct |
8 |
Correct |
2 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
73 ms |
1296 KB |
Output is correct |
12 |
Correct |
2 ms |
340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
12105 ms |
716 KB |
Output is correct |
2 |
Execution timed out |
20050 ms |
1000 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
651 ms |
16212 KB |
Output is correct |
2 |
Correct |
1206 ms |
16224 KB |
Output is correct |
3 |
Correct |
625 ms |
16224 KB |
Output is correct |
4 |
Correct |
647 ms |
17128 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
12038 ms |
716 KB |
Output is correct |
2 |
Execution timed out |
20053 ms |
1000 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
12878 ms |
716 KB |
Output is correct |
2 |
Execution timed out |
20031 ms |
1132 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |