Submission #586719

# Submission time Handle Problem Language Result Execution time Memory
586719 2022-06-30T14:55:07 Z AlperenT Wombats (IOI13_wombats) C++17
28 / 100
15091 ms 16360 KB
#include <bits/stdc++.h>
#include "wombats.h"

using namespace std;

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

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

bool vis[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 Runtime error 6 ms 8532 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 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 1 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 468 KB Output is correct
9 Correct 1 ms 596 KB Output is correct
10 Correct 1 ms 596 KB Output is correct
11 Correct 62 ms 1584 KB Output is correct
12 Correct 1 ms 596 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3968 ms 4492 KB Output is correct
2 Correct 2339 ms 4452 KB Output is correct
3 Correct 4043 ms 4488 KB Output is correct
4 Correct 4038 ms 4492 KB Output is correct
5 Correct 3915 ms 4460 KB Output is correct
6 Correct 0 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 15091 ms 4492 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 12 ms 16340 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3924 ms 4484 KB Output is correct
2 Correct 2342 ms 4448 KB Output is correct
3 Correct 3998 ms 4484 KB Output is correct
4 Correct 3989 ms 4488 KB Output is correct
5 Correct 3971 ms 4524 KB Output is correct
6 Runtime error 13 ms 16360 KB Execution killed with signal 11
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4059 ms 4492 KB Output is correct
2 Correct 2405 ms 4452 KB Output is correct
3 Correct 4190 ms 4604 KB Output is correct
4 Correct 4190 ms 4492 KB Output is correct
5 Correct 4149 ms 4456 KB Output is correct
6 Runtime error 15 ms 16268 KB Execution killed with signal 11
7 Halted 0 ms 0 KB -