Submission #586720

# Submission time Handle Problem Language Result Execution time Memory
586720 2022-06-30T14:56:08 Z AlperenT Wombats (IOI13_wombats) C++17
55 / 100
20000 ms 262144 KB
#include <bits/stdc++.h>
#include "wombats.h"

using namespace std;

const int N = 5000 + 1, M = 100, INF = 1e9 + 5;

int n, m, h[N][M], v[N][M], dist[M][N][M];

void calc_dist(){
	for(int lst = 0; lst < m; lst++){
		for(int c = 0; c < m; c++) dist[lst][n][c] = INF;
		dist[lst][n][lst] = 0;

		for(int r = n - 1; r >= 0; r--){
			vector<pair<int, int>> vec;

			for(int c = 0; c < m; c++){
				dist[lst][r][c] = dist[lst][r + 1][c] + v[r][c];

				vec.push_back({dist[lst][r][c], c});
			}

			sort(vec.begin(), vec.end());

			for(int i = 0; i < m; i++){
				int c = vec[i].second;

				int cur = c;

				while(cur != 0 && dist[lst][r][cur] + h[r][cur - 1] < dist[lst][r][cur - 1]){
					dist[lst][r][cur - 1] = dist[lst][r][cur] + h[r][cur - 1];
					cur--;
				}

				cur = c;

				while(cur != m - 1 && dist[lst][r][cur] + h[r][cur] < dist[lst][r][cur + 1]){
					dist[lst][r][cur + 1] = dist[lst][r][cur] + h[r][cur];
					cur++;
				}
			}
		}
	}
}

void init(int R, int C, int H[5000][200], int V[5000][200]) {
    n = R, m = C;

    for(int i = 0; i < n; i++){
    	for(int j = 0; j < m - 1; j++){
    		h[i][j] = H[i][j];
    	}
    }

    for(int i = 0; i < n - 1; i++){
    	for(int j = 0; j < m; j++){
    		v[i][j] = V[i][j];
    	}
    }

    calc_dist();
}

void changeH(int P, int Q, int W) {
    h[P][Q] = W;

    calc_dist();
}

void changeV(int P, int Q, int W) {
    v[P][Q] = W;

    calc_dist();
}

int escape(int V1, int V2) {
    return dist[V2][0][V1];
}

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 79 ms 8128 KB Output is correct
2 Correct 78 ms 8020 KB Output is correct
3 Correct 143 ms 9740 KB Output is correct
4 Correct 83 ms 8148 KB Output is correct
5 Correct 85 ms 8128 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 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 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 596 KB Output is correct
5 Correct 1 ms 596 KB Output is correct
6 Correct 1 ms 596 KB Output is correct
7 Correct 1 ms 596 KB Output is correct
8 Correct 1 ms 596 KB Output is correct
9 Correct 1 ms 596 KB Output is correct
10 Correct 1 ms 596 KB Output is correct
11 Correct 78 ms 1608 KB Output is correct
12 Correct 1 ms 596 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4073 ms 5244 KB Output is correct
2 Correct 2526 ms 5312 KB Output is correct
3 Correct 4281 ms 5276 KB Output is correct
4 Correct 4357 ms 5276 KB Output is correct
5 Correct 4161 ms 5232 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 16326 ms 5276 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 381 ms 15956 KB Output is correct
2 Correct 406 ms 15956 KB Output is correct
3 Correct 445 ms 15960 KB Output is correct
4 Correct 468 ms 16716 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4287 ms 5236 KB Output is correct
2 Correct 2348 ms 5188 KB Output is correct
3 Correct 4059 ms 5280 KB Output is correct
4 Correct 4000 ms 5276 KB Output is correct
5 Correct 3890 ms 5232 KB Output is correct
6 Correct 390 ms 15956 KB Output is correct
7 Correct 348 ms 15952 KB Output is correct
8 Correct 436 ms 15956 KB Output is correct
9 Correct 402 ms 16776 KB Output is correct
10 Correct 85 ms 8020 KB Output is correct
11 Correct 81 ms 8020 KB Output is correct
12 Correct 140 ms 9680 KB Output is correct
13 Correct 75 ms 8020 KB Output is correct
14 Correct 76 ms 8124 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 1 ms 596 KB Output is correct
19 Correct 1 ms 596 KB Output is correct
20 Correct 1 ms 596 KB Output is correct
21 Correct 1 ms 596 KB Output is correct
22 Correct 1 ms 596 KB Output is correct
23 Correct 2 ms 596 KB Output is correct
24 Correct 1 ms 596 KB Output is correct
25 Correct 66 ms 1600 KB Output is correct
26 Correct 1 ms 596 KB Output is correct
27 Correct 15375 ms 5280 KB Output is correct
28 Execution timed out 20105 ms 207784 KB Time limit exceeded
29 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3976 ms 5240 KB Output is correct
2 Correct 2342 ms 5188 KB Output is correct
3 Correct 4024 ms 5276 KB Output is correct
4 Correct 3977 ms 5280 KB Output is correct
5 Correct 3940 ms 5236 KB Output is correct
6 Correct 404 ms 15956 KB Output is correct
7 Correct 349 ms 15960 KB Output is correct
8 Correct 357 ms 15944 KB Output is correct
9 Correct 419 ms 16728 KB Output is correct
10 Correct 76 ms 8128 KB Output is correct
11 Correct 76 ms 8124 KB Output is correct
12 Correct 143 ms 9676 KB Output is correct
13 Correct 90 ms 8124 KB Output is correct
14 Correct 82 ms 8128 KB Output is correct
15 Runtime error 3047 ms 262144 KB Execution killed with signal 11
16 Halted 0 ms 0 KB -