#include "wombats.h"
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define MOD (1000000000+7)
#define MOD1 (998244353)
#define pb push_back
#define all(x) x.begin(), x.end()
#define en cout << '\n'
#define ff first
#define ss second
#define pii pair<int,int>
#define vi vector<int>
const int N = 100+100, M = 1e5+10, K = 52, MX = 30;
int T[5000*4][20][20], H[5000][200], V[5000][200], pref[5000][200];
int get_pref(int row, int l, int r){
if(r < l) swap(l, r);
return pref[row][r] - pref[row][l];
}
int n, m;
void build(int l, int r, int k){
if(l == r){
for(int j = 0; j < m; ++j){
for(int i = 0; i < m; ++i) T[k][j][i] = get_pref(l, j, i);
}
// cout << l << ' ' << r << " : ";
// for(int s = 0; s < m; ++s){
// for(int e = 0; e < m; ++e){
// cout << s << ' ' << e << ' ' << T[k][s][e] << '\n';
// }
// }
// en;
return;
}
int mid = l+r>>1;
build(l, mid, k<<1);
build(mid+1, r, k<<1|1);
for(int s = 0; s < m; ++s){
for(int e = 0; e < m; ++e){
T[k][s][e] = MOD;
for(int i = 0; i < m; ++i){
T[k][s][e] = min(T[k<<1][s][i] + T[k<<1|1][i][e] + V[mid][i], T[k][s][e]);
// if(s==0 && e == 2 && l == 0 && r == 1){
// cout << s << ' ' << i << ' ' << e << " ";
// cout << V[mid][i] << ' ' << T[k<<1][s][i] << ' ' << T[k<<1|1][i][e] << "f\n";
// }
}
}
}
// cout << l << ' ' << r << " : ";
// for(int s = 0; s < m; ++s){
// for(int e = 0; e < m; ++e){
// cout << s << ' ' << e << ' ' << T[k][s][e] << '\n';
// }
// }
}
void init(int R, int C, int HH[5000][200], int VV[5000][200]) {
n = R;
m = C;
for(int i = 0; i < n; ++i){
for(int j = 0 ;j < m; ++j){
H[i][j] = HH[i][j];
V[i][j] = VV[i][j];
if(j == 0) pref[i][0] = 0;
else pref[i][j] = pref[i][j - 1] + H[i][j - 1];
}
}
build(0, n - 1, 1);
}
void changeH(int P, int Q, int W) {
/* ... */
}
void changeV(int P, int Q, int W) {
/* ... */
}
int escape(int V1, int V2) {
return T[1][V1][V2];
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |