답안 #359451

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
359451 2021-01-27T03:04:41 Z tengiz05 웜뱃 (IOI13_wombats) C++17
12 / 100
1124 ms 16236 KB
#include "wombats.h"
#ifndef EVAL
#include "grader.c"
#endif
#include <bits/stdc++.h>
using namespace std;
int n, m;
int h[5000][200], v[5000][200];
int dp[200][200], old[200][200];
void recalc(){
	for(int start = 0; start < m; start++){
		int carry = 0;
		for(int i=start;i<m;i++){
			old[start][i] = carry;
			carry += h[0][i];
		}carry = 0;
		for(int i=start-1;i>=0;i--){
			carry += h[0][i];
			old[start][i] = carry;
		}
		for(int row=1;row<n;row++){
			for(int i=0;i<m;i++){
				dp[start][i] = old[start][i] + v[row-1][i];
			}
			for(int i=1;i<m;i++){
				dp[start][i] = min(dp[start][i], dp[start][i-1] + h[row][i-1]);
			}
			for(int i=m-2;i>=0;i--){
				dp[start][i] = min(dp[start][i], dp[start][i+1] + h[row][i]);
			}
			swap(dp[start],old[start]);
		}swap(dp[start],old[start]);
	}
	//~ cout << "______________________________\n";
	//~ cout << "what my dp looks like\n";
	//~ for(int i=0;i<m;i++){
		//~ for(int j=0;j<m;j++){
			//~ cout << dp[i][j] << ' ';
		//~ }cout << '\n';
	//~ }cout << "______________________________\n\n";
}
void init(int R, int C, int H[5000][200], int V[5000][200]){
	n = R, m = C;
	for(int i=0;i<5000;i++){
		for(int j=0;j<200;j++){
			h[i][j] = H[i][j];
			v[i][j] = V[i][j];
		}
	}recalc();
}

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

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

int escape(int V1, int V2){
	return dp[V1][V2];
}
/*


3 4
0 2 5
7 1 1
0 4 0
0 0 0 2
0 3 4 7
5
3 2 1
3 3 3
2 0 0 5
1 1 1 6
3 2 1



*/

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;
      |      ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 529 ms 12156 KB Output is correct
2 Incorrect 543 ms 12140 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 8172 KB Output is correct
2 Correct 8 ms 8172 KB Output is correct
3 Correct 7 ms 8172 KB Output is correct
4 Correct 7 ms 8300 KB Output is correct
5 Correct 7 ms 8300 KB Output is correct
6 Correct 7 ms 8300 KB Output is correct
7 Correct 7 ms 8300 KB Output is correct
8 Correct 7 ms 8300 KB Output is correct
9 Correct 7 ms 8300 KB Output is correct
10 Correct 7 ms 8300 KB Output is correct
11 Correct 90 ms 10604 KB Output is correct
12 Correct 7 ms 8300 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1124 ms 8756 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1117 ms 16236 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1115 ms 8832 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1108 ms 8556 KB Output isn't correct
2 Halted 0 ms 0 KB -