# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
374011 |
2021-03-06T12:25:51 Z |
MetB |
Wombats (IOI13_wombats) |
C++14 |
|
6687 ms |
18412 KB |
#include "wombats.h"
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
const ll N = 2000001;
const ll INF = 1e18, MOD = 1e9 + 7, MOD2 = 1e6 + 3;
int R, C, hor[5000][200], ver[5000][200];
struct cut {
vector<vector<int>> d;
cut() {
for (int i = 0; i < C; i++)
d.push_back(vector<int>(C, MOD));
}
cut(int pos) {
d = vector<vector<int>>(C);
for (int i = 0; i < C; i++)
d[i] = vector<int>(C, MOD);
for (int i = 0; i < C; i++)
d[i][i] = 0;
if (R <= pos) return;
for (int i = 0; i < C; i++) {
for (int j = i + 1; j < C; j++) {
d[i][j] = d[j][i] = d[i][j-1] + hor[pos][j-1];
}
}
/*cout << "Create on " << pos << endl;
for (int i = 0; i < C; i++) {
for (int j = 0; j < C; j++) {
cout << d[i][j] << ' ';
}
cout << endl;
}*/
}
vector<int>& operator[](int& x) {
return d[x];
}
};
cut merge(cut dl, cut dr, int pos) {
cut d;
/*vector<int> opt(C, -1);
for (int i = 0; i < C; i++) {
for (int j = 0; j < C; j++) {
if (d[i][i] > dl[i][j] + hor[pos][j] + dr[j][i]) {
opt[i] = j;
d[i][i] = dl[i][j] + hor[pos][j] + dr[j][i];
}
}
}
for (int k = 1; k < C; k++) {
for (int i = 0; i + k < C; i++) {
for (int j = opt[i]; j <= opt[i+1]; j++) {
if (d[i][i+k] > dl[i][j] + hor[pos][j] + dr[j][i+k]) {
opt[i] = j;
d[i][i+k] = dl[i][j] + hor[pos][j] + dr[j][i+k]
}
}
}
}*/
for (int i = 0; i < C; i++) {
for (int j = 0; j < C; j++) {
for (int k = 0; k < C; k++) {
d[i][j] = min(d[i][j], dl[i][k] + ver[pos][k] + dr[k][j]);
}
}
}
/*cout << "Merge on " << pos << endl;
for (int i = 0; i < C; i++) {
cout << ver[pos][i] << endl;
}
for (int i = 0; i < C; i++) {
for (int j = 0; j < C; j++) {
cout << d[i][j] << ' ';
}
cout << endl;
}*/
return d;
}
struct DynamicGrid {
int start;
vector<cut> t;
void build() {
start = 1;
while (start < R) start <<= 1;
t.resize(2 * start);
build(1, 0, start - 1, R);
}
void build(int node, int tl, int tr, int sz) {
if (tl == tr) {
t[node] = cut(tl);
return;
}
int tm = (tl + tr) / 2;
build(2 * node, tl, tm, sz);
build(2 * node + 1, tm + 1, tr, sz);
t[node] = merge(t[2 * node], t[2 * node + 1], tm);
}
void update(int x) {
update(1, 0, start - 1, x);
}
void update(int node, int tl, int tr, int x) {
if (x < tl || tr < x) return;
if (tl == tr) {
t[node] = cut(x);
return;
}
int tm = (tl + tr) / 2;
if (x <= tm) update(2 * node, tl, tm, x);
else update(2 * node + 1, tm + 1, tr, x);
t[node] = merge(t[2 * node], t[2 * node + 1], tm);
}
int get(int a, int b) {
//cout << "Get " << t[1][a][b] << endl;
return t[1][a][b];
}
} t;
void init(int r, int c, int H[5000][200], int V[5000][200]) {
R = r, C = c;
for (int i = 0; i < R; i++)
for (int j = 0; j < C; j++) {
hor[i][j] = H[i][j];
ver[i][j] = V[i][j];
}
t.build();
}
void changeH(int P, int Q, int W) {
hor[P][Q] = W;
t.update(P);
}
void changeV(int P, int Q, int W) {
ver[P][Q] = W;
t.update(P);
}
int escape(int V1, int V2) {
return t.get(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;
| ^~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
14 ms |
13420 KB |
Output is correct |
2 |
Correct |
13 ms |
13420 KB |
Output is correct |
3 |
Correct |
90 ms |
15084 KB |
Output is correct |
4 |
Correct |
14 ms |
13420 KB |
Output is correct |
5 |
Correct |
13 ms |
13420 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
0 ms |
364 KB |
Output is correct |
8 |
Correct |
0 ms |
364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
0 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
620 KB |
Output is correct |
5 |
Correct |
1 ms |
620 KB |
Output is correct |
6 |
Correct |
1 ms |
620 KB |
Output is correct |
7 |
Correct |
2 ms |
620 KB |
Output is correct |
8 |
Correct |
2 ms |
620 KB |
Output is correct |
9 |
Correct |
2 ms |
620 KB |
Output is correct |
10 |
Correct |
1 ms |
620 KB |
Output is correct |
11 |
Correct |
77 ms |
1644 KB |
Output is correct |
12 |
Correct |
1 ms |
620 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1519 ms |
12116 KB |
Output is correct |
2 |
Correct |
1367 ms |
12140 KB |
Output is correct |
3 |
Correct |
1497 ms |
12116 KB |
Output is correct |
4 |
Correct |
1393 ms |
12012 KB |
Output is correct |
5 |
Correct |
1357 ms |
12012 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
364 KB |
Output is correct |
9 |
Correct |
6687 ms |
12116 KB |
Output is correct |
10 |
Correct |
1 ms |
364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
20 ms |
18412 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1413 ms |
12116 KB |
Output is correct |
2 |
Correct |
1418 ms |
12232 KB |
Output is correct |
3 |
Correct |
1376 ms |
12140 KB |
Output is correct |
4 |
Correct |
1418 ms |
12140 KB |
Output is correct |
5 |
Correct |
1376 ms |
12140 KB |
Output is correct |
6 |
Incorrect |
23 ms |
18412 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1420 ms |
12012 KB |
Output is correct |
2 |
Correct |
1342 ms |
12012 KB |
Output is correct |
3 |
Correct |
1394 ms |
12116 KB |
Output is correct |
4 |
Correct |
1371 ms |
12116 KB |
Output is correct |
5 |
Correct |
1345 ms |
12140 KB |
Output is correct |
6 |
Incorrect |
24 ms |
18412 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |