Submission #798487

# Submission time Handle Problem Language Result Execution time Memory
798487 2023-07-30T18:29:43 Z QwertyPi Wombats (IOI13_wombats) C++14
55 / 100
20000 ms 26028 KB
#include "wombats.h"
#include <bits/stdc++.h>

using namespace std;
const int R_MAX = 5000;
const int C_MAX = 200;
const int K = 50;
const int INF = 1 << 30;
int R, C, H[R_MAX][C_MAX], V[R_MAX][C_MAX];
int A[R_MAX / K][C_MAX][C_MAX], B[C_MAX][C_MAX];
int DP[C_MAX][C_MAX];

void init(){
	for(int i = 0; i < C; i++) for(int j = 0; j < C; j++) DP[i][j] = i == j ? 0 : INF;
}

bool chmin(int& x, int y){
	if(x > y){
		x = y; return true;
	}
	return false;
}

void process(int row){
	for(int i = 0; i < C; i++){
		for(int j = 0; j < C; j++){
			for(int k = j - 1; k >= 0; k--){
				if(!chmin(DP[i][k], DP[i][k + 1] + H[row][k])){
					break;
				}
			}
			for(int k = j + 1; k < C; k++){
				if(!chmin(DP[i][k], DP[i][k - 1] + H[row][k - 1])){
					break;
				}
			}
		}
	}
	for(int i = 0; i < C; i++){
		for(int j = 0; j < C; j++){
			DP[i][j] += V[row][j];
		}
	}
}

void recalc(int part = -1){
	init();
	for(int r = 0; r < R; r++){
		process(r);
	}
	for(int i = 0; i < C; i++) 
		for(int j = 0; j < C; j++) 
			B[i][j] = DP[i][j];
}

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 - 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];
		}
	}
	recalc();
}

void changeH(int P, int Q, int W) {
	::H[P][Q] = W;
	recalc(P / K);
}

void changeV(int P, int Q, int W) {
	::V[P][Q] = W;
	recalc(P / K);
}

int escape(int V1, int V2) {
	return B[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 15 ms 8180 KB Output is correct
2 Correct 15 ms 8184 KB Output is correct
3 Correct 68 ms 10952 KB Output is correct
4 Correct 15 ms 8148 KB Output is correct
5 Correct 14 ms 8148 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 1 ms 312 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 312 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 440 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 436 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 56 ms 2732 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 326 ms 856 KB Output is correct
2 Correct 384 ms 852 KB Output is correct
3 Correct 321 ms 884 KB Output is correct
4 Correct 325 ms 852 KB Output is correct
5 Correct 308 ms 872 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 2350 ms 868 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 43 ms 15956 KB Output is correct
2 Correct 37 ms 15996 KB Output is correct
3 Correct 50 ms 16148 KB Output is correct
4 Correct 72 ms 17344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 319 ms 864 KB Output is correct
2 Correct 390 ms 860 KB Output is correct
3 Correct 317 ms 892 KB Output is correct
4 Correct 326 ms 872 KB Output is correct
5 Correct 309 ms 836 KB Output is correct
6 Correct 43 ms 16036 KB Output is correct
7 Correct 34 ms 15956 KB Output is correct
8 Correct 43 ms 15956 KB Output is correct
9 Correct 72 ms 17312 KB Output is correct
10 Correct 15 ms 8180 KB Output is correct
11 Correct 15 ms 8148 KB Output is correct
12 Correct 69 ms 10884 KB Output is correct
13 Correct 14 ms 8148 KB Output is correct
14 Correct 15 ms 8192 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 340 KB Output is correct
17 Correct 1 ms 312 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 56 ms 2728 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 2343 ms 872 KB Output is correct
28 Execution timed out 20073 ms 20096 KB Time limit exceeded
29 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 324 ms 864 KB Output is correct
2 Correct 383 ms 852 KB Output is correct
3 Correct 327 ms 972 KB Output is correct
4 Correct 332 ms 872 KB Output is correct
5 Correct 309 ms 932 KB Output is correct
6 Correct 43 ms 15956 KB Output is correct
7 Correct 35 ms 15932 KB Output is correct
8 Correct 43 ms 15956 KB Output is correct
9 Correct 72 ms 17352 KB Output is correct
10 Correct 15 ms 8148 KB Output is correct
11 Correct 15 ms 8148 KB Output is correct
12 Correct 72 ms 10912 KB Output is correct
13 Correct 19 ms 8148 KB Output is correct
14 Correct 14 ms 8192 KB Output is correct
15 Correct 1574 ms 26028 KB Output is correct
16 Execution timed out 20010 ms 24328 KB Time limit exceeded
17 Halted 0 ms 0 KB -