답안 #97015

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
97015 2019-02-13T10:28:56 Z E869120 웜뱃 (IOI13_wombats) C++14
37 / 100
4075 ms 104696 KB
#include "wombats.h"
#include <bits/stdc++.h>
using namespace std;

int H, W, size_, A1[5009][209], A2[5009][209], dat[16384][109][109]; bool ok[16384];

void update(int pos) {
	if (ok[pos * 2 + 1] == false) {
		for (int i = 0; i < W; i++) { for (int j = 0; j < W; j++) dat[pos][i][j] = dat[pos * 2][i][j]; }
		return;
	}
	int L = pos * 2, R = pos * 2 + 1;
	for (int i = 0; i < W; i++) { for (int j = 0; j < W; j++) dat[pos][i][j] = (1 << 30); }
	for (int i = 0; i < W; i++) {
		for (int j = 0; j < W; j++) {
			for (int k = 0; k < W; k++) dat[pos][i][k] = min(dat[pos][i][k], dat[L][i][j] + dat[R][j][k]);
		}
	}
}

void recharge(int pos, int B){
	pos += size_;
	for (int i = 0; i < W; i++) {
		dat[pos][i][i] = A2[pos - size_][i]; int s = 0;
		for (int j = i + 1; j < W; j++) {
			s += A1[pos - size_][j - 1];
			dat[pos][i][j] = s + A2[pos - size_][j];
		}
		s = 0;
		for (int j = i - 1; j >= 0; j--) {
			s += A1[pos - size_][j];
			dat[pos][i][j] = s + A2[pos - size_][j];
		}
	}
	while (pos >= 2) {
		if (B == 2 && pos % 2 == 0) break;
		pos /= 2;
		update(pos);
	}
}

void init(int R, int C, int I[5000][200], int V[5000][200]) {
	size_ = 1; while (size_ < R) size_ *= 2;
	H = R; W = C;
	for (int i = 0; i < H; i++) {
		int cx = i + size_; ok[cx] = true;
		while (cx >= 2) { cx /= 2; ok[cx] = true; }
	}
    for (int i = 0; i < H; i++) {
		for(int j = 0; j < W - 1; j++) A1[i][j] = I[i][j];
	}
	for (int i = 0; i < H - 1; i++) {
		for (int j = 0; j < W; j++) A2[i][j] = V[i][j];
	}
	for (int i = 0; i < size_; i++) recharge(i, 2);
	
	/*for (int i = 1; i < size_ * 2; i++) {
		cout<<i<<":"<<endl;
		for (int j = 0; j < W; j++) {
			for (int k = 0; k < W; k++) cout<<dat[i][j][k]<<" "; cout<<endl;
		}
		cout<<endl;
	}*/
}

void changeH(int P, int Q, int T) {
    A1[P][Q] = T;
    recharge(P, 1);
}

void changeV(int P, int Q, int T) {
    A2[P][Q] = T;
    recharge(P, 1);
}

int escape(int V1, int V2) {
	return dat[1][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]
  int res;
      ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 54 ms 75384 KB Output is correct
2 Correct 54 ms 75384 KB Output is correct
3 Correct 170 ms 76920 KB Output is correct
4 Correct 51 ms 75384 KB Output is correct
5 Correct 54 ms 75384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 4 ms 1152 KB Output is correct
5 Correct 5 ms 1280 KB Output is correct
6 Correct 3 ms 1152 KB Output is correct
7 Correct 4 ms 1152 KB Output is correct
8 Correct 3 ms 1152 KB Output is correct
9 Correct 3 ms 1152 KB Output is correct
10 Correct 4 ms 1152 KB Output is correct
11 Correct 92 ms 2168 KB Output is correct
12 Correct 4 ms 1152 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 983 ms 12696 KB Output is correct
2 Correct 951 ms 12520 KB Output is correct
3 Correct 924 ms 12536 KB Output is correct
4 Correct 955 ms 12664 KB Output is correct
5 Correct 940 ms 12536 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 3 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 4075 ms 12636 KB Output is correct
10 Correct 3 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 226 ms 104616 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1006 ms 12668 KB Output is correct
2 Correct 874 ms 12516 KB Output is correct
3 Correct 863 ms 12792 KB Output is correct
4 Correct 919 ms 12664 KB Output is correct
5 Correct 956 ms 12664 KB Output is correct
6 Runtime error 204 ms 104568 KB Execution killed with signal 11 (could be triggered by violating memory limits)
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 891 ms 12684 KB Output is correct
2 Correct 936 ms 12536 KB Output is correct
3 Correct 899 ms 12608 KB Output is correct
4 Correct 897 ms 12664 KB Output is correct
5 Correct 903 ms 12508 KB Output is correct
6 Runtime error 211 ms 104696 KB Execution killed with signal 11 (could be triggered by violating memory limits)
7 Halted 0 ms 0 KB -