#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define replr(i, a, b) for (int i = int(a); i <= int(b); ++i)
#define reprl(i, a, b) for (int i = int(a); i >= int(b); --i)
#define rep(i, n) for (int i = 0; i < int(n); ++i)
#define mkp(a, b) make_pair(a, b)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VPI;
typedef vector<VI> VVI;
typedef vector<VVI> VVVI;
typedef vector<VPI> VVPI;
typedef pair<ll, ll> PLL;
typedef vector<ll> VL;
typedef vector<PLL> VPL;
typedef vector<VL> VVL;
typedef vector<VVL> VVVL;
typedef vector<VPL> VVPL;
template<class T> T setmax(T& a, T b) {if (a < b) return a = b; return a;}
template<class T> T setmin(T& a, T b) {if (a < b) return a; return a = b;}
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template<class T>
using indset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#include "wombats.h"
const int MAXC = 100;
int n, m;
struct PART {
int d[MAXC][MAXC];
PART() {
clear();
}
void clear() {
rep(i, m) rep(j, m) d[i][j] = 1e9;
}
void add(const PART& b) {
PART c;
rep(u, m) rep(v, m) rep(mid, m) {
setmin(c.d[u][v], d[u][mid] + b.d[mid][v]);
}
rep(u, m) rep(v, m) d[u][v] = c.d[u][v];
}
void set(const PART& a, const PART& b) {
PART c;
rep(u, m) rep(v, m) rep(mid, m) {
setmin(c.d[u][v], a.d[u][mid] + b.d[mid][v]);
}
rep(u, m) rep(v, m) d[u][v] = c.d[u][v];
}
void print() {
rep(i, m) {
rep(j, m) cout << d[i][j] << " ";
cout << endl;
}
}
};
vector<PART> a;
PART answer;
VVI H, V;
struct SEGTREE {
int n;
vector<PART> tree;
SEGTREE(){}
SEGTREE(int sz) {
n = 1;
while (n < sz) n *= 2;
tree = vector<PART>(2*n);
rep(u, 2*n) {
/*rep(i, n) rep(j, m) {*/
rep(i, n) tree[u].d[i][i] = 0;
/*tree[u].d[0][0] = -1;*/
}
}
void upd(int N, int L, int R, int i, const PART& nw) {
if (i < L || i > R) return;
if (L == R) {
tree[N] = nw;
return;
}
int M = (L + R) / 2;
upd(2*N+1, L, M, i, nw);
upd(2*N+2, M+1, R, i, nw);
tree[N].set(tree[2*N+1], tree[2*N+2]);
}
void upd(int i, const PART& nw) {
upd(0, 0, n-1, i, nw);
}
void print() {
rep(u, 2*n-1) {
cout << u << ": " << endl;
tree[u].print();
}
}
} seg;
void recalcpart(int ind) {
replr(i, 0, m-1) {
int sum = 0;
replr(j, i, m-1) {
a[ind].d[i][j] = sum + V[ind][j];
a[ind].d[j][i] = sum + V[ind][i];
sum += H[ind][j];
}
}
}
void recalc() {
rep(u, n) a[u].clear();
rep(u, n) {
recalcpart(u);
}
answer = a[0];
replr(i, 1, n-1) answer.add(a[i]);
}
void init(int R, int C, int H_arg[5000][200], int V_arg[5000][200]) {
n = R;
m = C;
H = V = VVI(n, VI(m));
rep(i, n) rep(j, m-1) H[i][j] = H_arg[i][j];
rep(i, n-1) rep(j, m) V[i][j] = V_arg[i][j];
a = vector<PART>(n);
rep(i, n) recalcpart(i);
seg = SEGTREE(n);
rep(u, n) seg.upd(u, a[u]);
answer = a[0];
replr(i, 1, n-1) answer.add(a[i]);
/*seg.print();*/
}
void changeH(int P, int Q, int W) {
H[P][Q] = W;
recalc(); return;
recalcpart(P);
/*seg.upd(P, a[P]);*/
answer = a[0];
replr(i, 1, n-1) answer.add(a[i]);
/*cout << "------------------------------------" << endl;*/
/*seg.tree[0].print();*/
/*cout << "------------------------------------" << endl;*/
/*answer.print();*/
/*cout << "------------------------------------" << endl;*/
}
void changeV(int P, int Q, int W) {
V[P][Q] = W;
recalc(); return;
recalcpart(P);
/*seg.upd(P, a[P]);*/
answer = a[0];
replr(i, 1, n-1) answer.add(a[i]);
/*cout << "------------------------------------" << endl;*/
/*seg.tree[0].print();*/
/*cout << "------------------------------------" << endl;*/
/*answer.print();*/
/*cout << "------------------------------------" << endl;*/
}
int escape(int u, int v) {
/*return seg.tree[0].d[u][v];*/
return answer.d[u][v];
}
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 |
Runtime error |
136 ms |
262144 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
600 KB |
Output is correct |
2 |
Correct |
0 ms |
604 KB |
Output is correct |
3 |
Correct |
0 ms |
604 KB |
Output is correct |
4 |
Correct |
2 ms |
2140 KB |
Output is correct |
5 |
Correct |
2 ms |
2140 KB |
Output is correct |
6 |
Correct |
2 ms |
2140 KB |
Output is correct |
7 |
Correct |
2 ms |
2140 KB |
Output is correct |
8 |
Correct |
2 ms |
2140 KB |
Output is correct |
9 |
Correct |
2 ms |
2140 KB |
Output is correct |
10 |
Correct |
2 ms |
2140 KB |
Output is correct |
11 |
Correct |
35 ms |
4648 KB |
Output is correct |
12 |
Correct |
2 ms |
2392 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7385 ms |
14948 KB |
Output is correct |
2 |
Correct |
6524 ms |
14680 KB |
Output is correct |
3 |
Correct |
7520 ms |
14684 KB |
Output is correct |
4 |
Correct |
7605 ms |
14780 KB |
Output is correct |
5 |
Correct |
7472 ms |
14684 KB |
Output is correct |
6 |
Correct |
1 ms |
604 KB |
Output is correct |
7 |
Correct |
0 ms |
604 KB |
Output is correct |
8 |
Correct |
0 ms |
604 KB |
Output is correct |
9 |
Execution timed out |
20091 ms |
14752 KB |
Time limit exceeded |
10 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
147 ms |
262144 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7495 ms |
14688 KB |
Output is correct |
2 |
Correct |
6613 ms |
14716 KB |
Output is correct |
3 |
Correct |
7631 ms |
14780 KB |
Output is correct |
4 |
Correct |
7974 ms |
14756 KB |
Output is correct |
5 |
Correct |
7939 ms |
14736 KB |
Output is correct |
6 |
Runtime error |
151 ms |
262144 KB |
Execution killed with signal 9 |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7773 ms |
14680 KB |
Output is correct |
2 |
Correct |
7415 ms |
14724 KB |
Output is correct |
3 |
Correct |
8157 ms |
14680 KB |
Output is correct |
4 |
Correct |
8137 ms |
14772 KB |
Output is correct |
5 |
Correct |
7891 ms |
14772 KB |
Output is correct |
6 |
Runtime error |
147 ms |
262144 KB |
Execution killed with signal 9 |
7 |
Halted |
0 ms |
0 KB |
- |