Submission #287212

# Submission time Handle Problem Language Result Execution time Memory
287212 2020-08-31T13:49:23 Z TMJN Wombats (IOI13_wombats) C++17
76 / 100
20000 ms 22720 KB
#include "wombats.h"
#include <bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;

const int bucket_size=1000;
int H,W,K[200][200][5],A[5100][200],B[5100][200],L[200][200];

void update(int x){
	int T[200];
	for(int i=0;i<W;i++){
		for(int j=0;j<W;j++){
			T[j]=0xE869120;
		}
		T[i]=0;
		for(int j=bucket_size*x;j<(bucket_size)*(x+1)&&j<H;j++){
			for(int k=0;k<W-1;k++){
				T[k+1]=min(T[k+1],T[k]+A[j][k]);
			}
			for(int k=W-2;k>=0;k--){
				T[k]=min(T[k],T[k+1]+A[j][k]);
			}
			for(int k=0;k<W;k++){
				T[k]+=B[j][k];
			}
		}
		for(int j=0;j<W;j++){
			K[i][j][x]=T[j];
		}
	}
}

void update_whole(){
	for(int i=0;i<W;i++){
		for(int j=0;j<W;j++){
			L[i][j]=K[i][j][0];
		}
	}
	for(int i=1;i*bucket_size<H;i++){
		for(int j=0;j<W;j++){
			int T[200];
			for(int k=0;k<W;k++){
				T[k]=0xE869120;
				for(int l=0;l<W;l++){
					T[k]=min(T[k],L[j][l]+K[l][k][i]);
				}
			}
			for(int k=0;k<W;k++){
				L[j][k]=T[k];
			}
		}
	}
}

void init(int R, int C, int h[5000][200], int v[5000][200]) {
    H=R;
    W=C;
    for(int i=0;i<H;i++){
		for(int j=0;j<W-1;j++){
			A[i][j]=h[i][j];
		}
	}
	for(int i=0;i<H-1;i++){
		for(int j=0;j<W;j++){
			B[i][j]=v[i][j];
		}
	}
	for(int i=0;i*bucket_size<H;i++){
		update(i);
	}
	update_whole();
}

void changeH(int P, int Q, int W) {
	A[P][Q]=W;
	update(P/bucket_size);
	update_whole();
}

void changeV(int P, int Q, int W) {
    B[P][Q]=W;
    update(P/bucket_size);
    update_whole();
}

int escape(int V1, int V2) {
	return L[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 8 ms 8192 KB Output is correct
2 Correct 7 ms 8192 KB Output is correct
3 Correct 97 ms 9720 KB Output is correct
4 Correct 7 ms 8192 KB Output is correct
5 Correct 7 ms 8192 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 0 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 512 KB Output is correct
5 Correct 1 ms 512 KB Output is correct
6 Correct 1 ms 512 KB Output is correct
7 Correct 1 ms 512 KB Output is correct
8 Correct 1 ms 512 KB Output is correct
9 Correct 1 ms 512 KB Output is correct
10 Correct 1 ms 512 KB Output is correct
11 Correct 93 ms 1480 KB Output is correct
12 Correct 1 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 345 ms 1172 KB Output is correct
2 Correct 339 ms 1172 KB Output is correct
3 Correct 353 ms 1272 KB Output is correct
4 Correct 351 ms 1272 KB Output is correct
5 Correct 355 ms 1152 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1707 ms 1180 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 22 ms 16000 KB Output is correct
2 Correct 24 ms 16000 KB Output is correct
3 Correct 22 ms 16000 KB Output is correct
4 Correct 66 ms 16760 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 347 ms 1272 KB Output is correct
2 Correct 344 ms 1152 KB Output is correct
3 Correct 350 ms 1272 KB Output is correct
4 Correct 354 ms 1152 KB Output is correct
5 Correct 341 ms 1272 KB Output is correct
6 Correct 22 ms 16000 KB Output is correct
7 Correct 22 ms 16000 KB Output is correct
8 Correct 23 ms 16000 KB Output is correct
9 Correct 65 ms 16760 KB Output is correct
10 Correct 7 ms 8192 KB Output is correct
11 Correct 7 ms 8192 KB Output is correct
12 Correct 93 ms 9720 KB Output is correct
13 Correct 7 ms 8192 KB Output is correct
14 Correct 7 ms 8192 KB Output is correct
15 Correct 0 ms 384 KB Output is correct
16 Correct 0 ms 384 KB Output is correct
17 Correct 0 ms 384 KB Output is correct
18 Correct 1 ms 512 KB Output is correct
19 Correct 1 ms 512 KB Output is correct
20 Correct 1 ms 512 KB Output is correct
21 Correct 1 ms 512 KB Output is correct
22 Correct 1 ms 512 KB Output is correct
23 Correct 1 ms 512 KB Output is correct
24 Correct 1 ms 512 KB Output is correct
25 Correct 94 ms 1528 KB Output is correct
26 Correct 1 ms 640 KB Output is correct
27 Correct 1721 ms 1272 KB Output is correct
28 Correct 19748 ms 17216 KB Output is correct
29 Correct 19699 ms 18088 KB Output is correct
30 Correct 17950 ms 17912 KB Output is correct
31 Correct 19831 ms 22720 KB Output is correct
32 Correct 1 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 350 ms 1152 KB Output is correct
2 Correct 345 ms 1272 KB Output is correct
3 Correct 351 ms 1152 KB Output is correct
4 Correct 348 ms 1180 KB Output is correct
5 Correct 345 ms 1280 KB Output is correct
6 Correct 22 ms 16000 KB Output is correct
7 Correct 21 ms 16000 KB Output is correct
8 Correct 24 ms 16000 KB Output is correct
9 Correct 64 ms 16888 KB Output is correct
10 Correct 8 ms 8320 KB Output is correct
11 Correct 7 ms 8192 KB Output is correct
12 Correct 93 ms 9720 KB Output is correct
13 Correct 7 ms 8192 KB Output is correct
14 Correct 7 ms 8192 KB Output is correct
15 Correct 1653 ms 17024 KB Output is correct
16 Execution timed out 20076 ms 17616 KB Time limit exceeded
17 Halted 0 ms 0 KB -