Submission #108185

# Submission time Handle Problem Language Result Execution time Memory
108185 2019-04-28T00:28:38 Z ihdignite Wombats (IOI13_wombats) C++14
100 / 100
4670 ms 175712 KB
#include "wombats.h"
#include <bits/stdc++.h>
using namespace std;

const int r=5e3, c=200, bs=10, bc=r/bs, sts=1024;
int h[r][c-1], v[r][c], st[sts][c][c], o[c][c];

void upd(int l1, int r1, int i=1, int l2=0, int r2=bc-1) {
	if(l2==r2) {
		memset(st[i], 0x3f, sizeof(st[i]));
		for(int j=0; j<c; ++j) {
			st[i][j][j]=0;
			for(int k=l2*bs; k<(l2+1)*bs; ++k) {
				for(int l=1; l<c; ++l)
					st[i][j][l]=min(st[i][j][l-1]+h[k][l-1], st[i][j][l]);
				for(int l=c-1; l; --l)
					st[i][j][l-1]=min(st[i][j][l]+h[k][l-1], st[i][j][l-1]);
				for(int l=0; l<c; ++l)
					st[i][j][l]+=v[k][l];
			}
		}
		return;
	}
	int m2=(l2+r2)/2;
	if(l1<=m2)
		upd(l1, r1, 2*i, l2, m2);
	if(m2<r1)
		upd(l1, r1, 2*i+1, m2+1, r2);
	for(int j1=0; j1<c; ++j1) {
		array<int, 2> d{INT_MAX, 0};
		for(int k=0; k<c; ++k)
			d=min(array<int, 2>{st[2*i][j1][k]+st[2*i+1][k][j1], -k}, d);
		st[i][j1][j1]=d[0];
		o[j1][j1]=-d[1];
		for(int j2=j1-1; ~j2; --j2) {
			d={INT_MAX, 0};
			for(int k=o[j1-1][j2]; k<=o[j1][j2+1]; ++k)
				d=min(array<int, 2>{st[2*i][j1][k]+st[2*i+1][k][j2], -k}, d);
			st[i][j1][j2]=d[0];
			o[j1][j2]=-d[1];
			d={INT_MAX, 0};
			for(int k=o[j2][j1-1]; k<=o[j2+1][j1]; ++k)
				d=min(array<int, 2>{st[2*i][j2][k]+st[2*i+1][k][j1], -k}, d);
			st[i][j2][j1]=d[0];
			o[j2][j1]=-d[1];
		}
	}
}

void init(int r, int c, int h[5000][200], int v[5000][200]) {
	memset(::h, 0x3f, sizeof(::h));
	for(int i=0; i<r; ++i)
		for(int j=0; j<c-1; ++j)
			::h[i][j]=h[i][j];
	for(int i=0; i<r-1; ++i)
		for(int j=0; j<c; ++j)
			::v[i][j]=v[i][j];
	upd(0, bc-1);
}

void changeH(int p, int q, int w) {
	h[p][q]=w;
	upd(p/bs, p/bs);
}

void changeV(int p, int q, int w) {
	v[p][q]=w;
	upd(p/bs, p/bs);
}

int escape(int a, int b) {
	return st[1][a][b];
}

Compilation message

grader.c: In function 'int main()':
grader.c:15:6: warning: variable 'res' set but not used [-Wunused-but-set-variable]
  int res;
      ^~~
wombats.cpp: In function 'void upd(int, int, int, int, int)':
wombats.cpp:73:1: warning: assuming signed overflow does not occur when assuming that (X + c) >= X is always true [-Wstrict-overflow]
 }
 ^
wombats.cpp:73:1: warning: assuming signed overflow does not occur when assuming that (X + c) >= X is always true [-Wstrict-overflow]
wombats.cpp:73:1: warning: assuming signed overflow does not occur when assuming that (X + c) >= X is always true [-Wstrict-overflow]
wombats.cpp:8:6: warning: assuming signed overflow does not occur when assuming that (X + c) >= X is always true [-Wstrict-overflow]
 void upd(int l1, int r1, int i=1, int l2=0, int r2=bc-1) {
      ^~~
wombats.cpp:8:6: warning: assuming signed overflow does not occur when assuming that (X + c) >= X is always true [-Wstrict-overflow]
wombats.cpp:8:6: warning: assuming signed overflow does not occur when assuming that (X + c) >= X is always true [-Wstrict-overflow]
# Verdict Execution time Memory Grader output
1 Correct 4436 ms 168672 KB Output is correct
2 Correct 4282 ms 168676 KB Output is correct
3 Correct 4170 ms 170940 KB Output is correct
4 Correct 3914 ms 168732 KB Output is correct
5 Correct 4058 ms 168768 KB Output is correct
6 Correct 1261 ms 160888 KB Output is correct
7 Correct 1278 ms 161044 KB Output is correct
8 Correct 1253 ms 160928 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1277 ms 160920 KB Output is correct
2 Correct 1304 ms 160812 KB Output is correct
3 Correct 1306 ms 160960 KB Output is correct
4 Correct 1239 ms 161016 KB Output is correct
5 Correct 1328 ms 161056 KB Output is correct
6 Correct 1298 ms 160972 KB Output is correct
7 Correct 1292 ms 161016 KB Output is correct
8 Correct 1244 ms 161016 KB Output is correct
9 Correct 1348 ms 161144 KB Output is correct
10 Correct 1265 ms 160972 KB Output is correct
11 Correct 1383 ms 162772 KB Output is correct
12 Correct 1278 ms 160888 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1723 ms 161276 KB Output is correct
2 Correct 1750 ms 161208 KB Output is correct
3 Correct 1880 ms 161284 KB Output is correct
4 Correct 1711 ms 161276 KB Output is correct
5 Correct 1786 ms 161232 KB Output is correct
6 Correct 1290 ms 160840 KB Output is correct
7 Correct 1262 ms 160904 KB Output is correct
8 Correct 1305 ms 160816 KB Output is correct
9 Correct 3786 ms 161168 KB Output is correct
10 Correct 1315 ms 160852 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4049 ms 172844 KB Output is correct
2 Correct 4347 ms 172680 KB Output is correct
3 Correct 4190 ms 172776 KB Output is correct
4 Correct 3959 ms 174124 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1933 ms 161288 KB Output is correct
2 Correct 1796 ms 161148 KB Output is correct
3 Correct 1797 ms 161356 KB Output is correct
4 Correct 1923 ms 161408 KB Output is correct
5 Correct 1829 ms 161144 KB Output is correct
6 Correct 3976 ms 172664 KB Output is correct
7 Correct 4165 ms 172728 KB Output is correct
8 Correct 4494 ms 172672 KB Output is correct
9 Correct 4353 ms 174056 KB Output is correct
10 Correct 4154 ms 168672 KB Output is correct
11 Correct 4024 ms 168888 KB Output is correct
12 Correct 4304 ms 170820 KB Output is correct
13 Correct 4172 ms 168784 KB Output is correct
14 Correct 4494 ms 168672 KB Output is correct
15 Correct 1297 ms 160868 KB Output is correct
16 Correct 1305 ms 160892 KB Output is correct
17 Correct 1285 ms 160840 KB Output is correct
18 Correct 1358 ms 160828 KB Output is correct
19 Correct 1292 ms 160800 KB Output is correct
20 Correct 1312 ms 160848 KB Output is correct
21 Correct 1304 ms 160852 KB Output is correct
22 Correct 1262 ms 160804 KB Output is correct
23 Correct 1211 ms 160812 KB Output is correct
24 Correct 1306 ms 160828 KB Output is correct
25 Correct 1330 ms 162748 KB Output is correct
26 Correct 1186 ms 160880 KB Output is correct
27 Correct 3927 ms 161156 KB Output is correct
28 Correct 4326 ms 174364 KB Output is correct
29 Correct 4567 ms 172288 KB Output is correct
30 Correct 3946 ms 172304 KB Output is correct
31 Correct 4590 ms 175324 KB Output is correct
32 Correct 1296 ms 160900 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1782 ms 161228 KB Output is correct
2 Correct 1792 ms 161240 KB Output is correct
3 Correct 1750 ms 161192 KB Output is correct
4 Correct 1799 ms 161160 KB Output is correct
5 Correct 1694 ms 161400 KB Output is correct
6 Correct 4302 ms 172756 KB Output is correct
7 Correct 3876 ms 172688 KB Output is correct
8 Correct 4038 ms 172632 KB Output is correct
9 Correct 4323 ms 174108 KB Output is correct
10 Correct 4467 ms 168844 KB Output is correct
11 Correct 4059 ms 168768 KB Output is correct
12 Correct 4471 ms 171076 KB Output is correct
13 Correct 4073 ms 168832 KB Output is correct
14 Correct 4064 ms 168676 KB Output is correct
15 Correct 1391 ms 174072 KB Output is correct
16 Correct 4313 ms 175712 KB Output is correct
17 Correct 1262 ms 160932 KB Output is correct
18 Correct 1394 ms 160956 KB Output is correct
19 Correct 1237 ms 161032 KB Output is correct
20 Correct 1236 ms 160908 KB Output is correct
21 Correct 1269 ms 161016 KB Output is correct
22 Correct 1359 ms 160936 KB Output is correct
23 Correct 1273 ms 160852 KB Output is correct
24 Correct 1359 ms 161024 KB Output is correct
25 Correct 1246 ms 160916 KB Output is correct
26 Correct 1227 ms 160776 KB Output is correct
27 Correct 1371 ms 162888 KB Output is correct
28 Correct 1338 ms 160900 KB Output is correct
29 Correct 4415 ms 161180 KB Output is correct
30 Correct 4604 ms 174588 KB Output is correct
31 Correct 4303 ms 174792 KB Output is correct
32 Correct 4465 ms 174776 KB Output is correct
33 Correct 4469 ms 172392 KB Output is correct
34 Correct 4537 ms 172860 KB Output is correct
35 Correct 3873 ms 172424 KB Output is correct
36 Correct 4318 ms 172700 KB Output is correct
37 Correct 4365 ms 175444 KB Output is correct
38 Correct 4192 ms 174480 KB Output is correct
39 Correct 1286 ms 160780 KB Output is correct
40 Correct 4670 ms 171628 KB Output is correct