# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
505222 |
2022-01-11T01:31:28 Z |
jhnah917 |
Wombats (IOI13_wombats) |
C++14 |
|
6038 ms |
229172 KB |
#include "wombats.h"
#include <bits/stdc++.h>
using namespace std;
int n, m, q;
int h[5050][222];
int v[5050][222];
struct Node{
Node *l, *r;
int data[222][222];
Node() : l(0), r(0) {
memset(data, 0, sizeof data);
}
};
void merge(int a[222][222], int b[222][222], int c[222][222]){ //a = b + c
int K[222][222] = {0};
for(int d=1-m; d<m; d++){
for(int i=1; i<=m; i++){
int j = i + d;
if(j < 1 || j > m) continue;
a[i][j] = 1e9+7;
int l = K[i][j-1] ? K[i][j-1] : 1;
int r = K[i+1][j] ? K[i+1][j] : m;
for(int k=l; k<=r; k++){
if(a[i][j] > b[i][k] + c[k][j]) a[i][j] = b[i][k] + c[k][j], K[i][j] = k;
}
}
}
}
void small(int data[222][222], int s, int e){
for(int i=1; i<=m; i++) for(int j=1; j<=m; j++) data[i][j] = 1e9+7;
for(int i=1; i<=m; i++) data[i][i] = 0;
int sum[222] = {0}, a[222][222] = {0}, b[222][222] = {0};
for(int i=s; i<=e+1; i++){
for(int j=1; j<=m; j++){
for(int k=1; k<=m; k++){
a[j][k] = data[j][k];
if(i != s) a[j][k] += v[i-1][k];
}
}
for(int j=2; j<=m; j++) sum[j] = sum[j-1] + h[i][j-1];
for(int j=1; j<=m; j++){
for(int k=j; k<=m; k++){
b[j][k] = b[k][j] = sum[k] - sum[j];
}
}
merge(data, a, b);
}
}
Node* build(int s, int e){
Node *ret = new Node();
if(e-s < 15){
small(ret->data, s, e);
return ret;
}
int m = s + e >> 1;
ret->l = build(s, m);
ret->r = build(m+1, e);
merge(ret->data, ret->l->data, ret->r->data);
return ret;
}
void update(Node *node, int s, int e, int l, int r){
if(r < s || e < l) return;
if(e-s < 15){
small(node->data, s, e);
return;
}
int m = s + e >> 1;
update(node->l, s, m, l, r);
update(node->r, m+1, e, l, r);
merge(node->data, node->l->data, node->r->data);
}
Node *root;
void init(int R, int C, int H[5000][200], int V[5000][200]){
n = R; m = C;
for(int i=1; i<=n; i++) for(int j=1; j<m; j++) h[i][j] = H[i-1][j-1];
for(int i=1; i<n; i++) for(int j=1; j<=m; j++) v[i][j] = V[i-1][j-1];
root = build(1, n-1);
}
void changeH(int i, int j, int k){
i++; j++; h[i][j] = k;
update(root, 1, n-1, i-1, i);
}
void changeV(int i, int j, int k){
i++; j++; v[i][j] = k;
update(root, 1, n-1, i, i);
}
int escape(int i, int j){
i++; j++;
return root->data[i][j];
}
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;
| ^~~
wombats.cpp: In function 'Node* build(int, int)':
wombats.cpp:59:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
59 | int m = s + e >> 1;
| ~~^~~
wombats.cpp: In function 'void update(Node*, int, int, int, int)':
wombats.cpp:72:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
72 | int m = s + e >> 1;
| ~~^~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
167 ms |
210180 KB |
Output is correct |
2 |
Correct |
161 ms |
210052 KB |
Output is correct |
3 |
Correct |
240 ms |
212756 KB |
Output is correct |
4 |
Correct |
160 ms |
209972 KB |
Output is correct |
5 |
Correct |
166 ms |
210012 KB |
Output is correct |
6 |
Correct |
1 ms |
972 KB |
Output is correct |
7 |
Correct |
1 ms |
972 KB |
Output is correct |
8 |
Correct |
1 ms |
972 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1068 KB |
Output is correct |
2 |
Correct |
1 ms |
972 KB |
Output is correct |
3 |
Correct |
1 ms |
1100 KB |
Output is correct |
4 |
Correct |
1 ms |
1456 KB |
Output is correct |
5 |
Correct |
1 ms |
1484 KB |
Output is correct |
6 |
Correct |
1 ms |
1484 KB |
Output is correct |
7 |
Correct |
1 ms |
1456 KB |
Output is correct |
8 |
Correct |
1 ms |
1484 KB |
Output is correct |
9 |
Correct |
1 ms |
1460 KB |
Output is correct |
10 |
Correct |
1 ms |
1484 KB |
Output is correct |
11 |
Correct |
75 ms |
3876 KB |
Output is correct |
12 |
Correct |
1 ms |
1484 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
199 ms |
4292 KB |
Output is correct |
2 |
Correct |
138 ms |
4252 KB |
Output is correct |
3 |
Correct |
186 ms |
4256 KB |
Output is correct |
4 |
Correct |
182 ms |
4236 KB |
Output is correct |
5 |
Correct |
187 ms |
4276 KB |
Output is correct |
6 |
Correct |
1 ms |
1064 KB |
Output is correct |
7 |
Correct |
1 ms |
972 KB |
Output is correct |
8 |
Correct |
1 ms |
972 KB |
Output is correct |
9 |
Correct |
691 ms |
4244 KB |
Output is correct |
10 |
Correct |
1 ms |
1100 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
169 ms |
218288 KB |
Output is correct |
2 |
Correct |
168 ms |
218284 KB |
Output is correct |
3 |
Correct |
168 ms |
218252 KB |
Output is correct |
4 |
Correct |
203 ms |
219728 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
196 ms |
4244 KB |
Output is correct |
2 |
Correct |
138 ms |
4132 KB |
Output is correct |
3 |
Correct |
197 ms |
4252 KB |
Output is correct |
4 |
Correct |
180 ms |
4172 KB |
Output is correct |
5 |
Correct |
186 ms |
4248 KB |
Output is correct |
6 |
Correct |
164 ms |
218364 KB |
Output is correct |
7 |
Correct |
174 ms |
218316 KB |
Output is correct |
8 |
Correct |
168 ms |
218276 KB |
Output is correct |
9 |
Correct |
200 ms |
219648 KB |
Output is correct |
10 |
Correct |
204 ms |
210124 KB |
Output is correct |
11 |
Correct |
159 ms |
209988 KB |
Output is correct |
12 |
Correct |
224 ms |
212732 KB |
Output is correct |
13 |
Correct |
162 ms |
210072 KB |
Output is correct |
14 |
Correct |
160 ms |
210016 KB |
Output is correct |
15 |
Correct |
1 ms |
1100 KB |
Output is correct |
16 |
Correct |
1 ms |
972 KB |
Output is correct |
17 |
Correct |
1 ms |
1044 KB |
Output is correct |
18 |
Correct |
1 ms |
1436 KB |
Output is correct |
19 |
Correct |
1 ms |
1436 KB |
Output is correct |
20 |
Correct |
1 ms |
1444 KB |
Output is correct |
21 |
Correct |
1 ms |
1460 KB |
Output is correct |
22 |
Correct |
1 ms |
1484 KB |
Output is correct |
23 |
Correct |
1 ms |
1456 KB |
Output is correct |
24 |
Correct |
1 ms |
1484 KB |
Output is correct |
25 |
Correct |
61 ms |
4004 KB |
Output is correct |
26 |
Correct |
1 ms |
1456 KB |
Output is correct |
27 |
Correct |
761 ms |
4268 KB |
Output is correct |
28 |
Correct |
1577 ms |
222484 KB |
Output is correct |
29 |
Correct |
1557 ms |
218360 KB |
Output is correct |
30 |
Correct |
1561 ms |
219216 KB |
Output is correct |
31 |
Correct |
1511 ms |
224188 KB |
Output is correct |
32 |
Correct |
1 ms |
1044 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
186 ms |
4144 KB |
Output is correct |
2 |
Correct |
136 ms |
4236 KB |
Output is correct |
3 |
Correct |
189 ms |
4168 KB |
Output is correct |
4 |
Correct |
187 ms |
4252 KB |
Output is correct |
5 |
Correct |
183 ms |
4172 KB |
Output is correct |
6 |
Correct |
172 ms |
218404 KB |
Output is correct |
7 |
Correct |
166 ms |
218308 KB |
Output is correct |
8 |
Correct |
166 ms |
218312 KB |
Output is correct |
9 |
Correct |
196 ms |
219704 KB |
Output is correct |
10 |
Correct |
162 ms |
209960 KB |
Output is correct |
11 |
Correct |
158 ms |
209988 KB |
Output is correct |
12 |
Correct |
226 ms |
212784 KB |
Output is correct |
13 |
Correct |
161 ms |
210076 KB |
Output is correct |
14 |
Correct |
176 ms |
209960 KB |
Output is correct |
15 |
Correct |
2056 ms |
228092 KB |
Output is correct |
16 |
Correct |
6038 ms |
229172 KB |
Output is correct |
17 |
Correct |
1 ms |
972 KB |
Output is correct |
18 |
Correct |
1 ms |
1068 KB |
Output is correct |
19 |
Correct |
1 ms |
972 KB |
Output is correct |
20 |
Correct |
1 ms |
1484 KB |
Output is correct |
21 |
Correct |
1 ms |
1456 KB |
Output is correct |
22 |
Correct |
1 ms |
1484 KB |
Output is correct |
23 |
Correct |
1 ms |
1476 KB |
Output is correct |
24 |
Correct |
1 ms |
1484 KB |
Output is correct |
25 |
Correct |
1 ms |
1452 KB |
Output is correct |
26 |
Correct |
1 ms |
1484 KB |
Output is correct |
27 |
Correct |
65 ms |
3840 KB |
Output is correct |
28 |
Correct |
2 ms |
1476 KB |
Output is correct |
29 |
Correct |
728 ms |
4244 KB |
Output is correct |
30 |
Correct |
1398 ms |
222388 KB |
Output is correct |
31 |
Correct |
4932 ms |
226764 KB |
Output is correct |
32 |
Correct |
4926 ms |
226656 KB |
Output is correct |
33 |
Correct |
1496 ms |
218560 KB |
Output is correct |
34 |
Correct |
5440 ms |
222524 KB |
Output is correct |
35 |
Correct |
1524 ms |
219216 KB |
Output is correct |
36 |
Correct |
5305 ms |
223048 KB |
Output is correct |
37 |
Correct |
1454 ms |
224172 KB |
Output is correct |
38 |
Correct |
5148 ms |
227292 KB |
Output is correct |
39 |
Correct |
1 ms |
1064 KB |
Output is correct |
40 |
Correct |
5495 ms |
222916 KB |
Output is correct |