Submission #63163

# Submission time Handle Problem Language Result Execution time Memory
63163 2018-08-01T01:34:57 Z khsoo01 Treasure (different grader from official contest) (CEOI13_treasure2) C++11
100 / 100
4 ms 900 KB
#include "treasure.h"

int n, a[105][105], c[4][105][105];

int px[105], sx[105], py[105], sy[105], aa;

int getc (int K, int A, int B) {
	if(~c[K][A][B]) return c[K][A][B];
	int R;
	if(K == 0) R = countTreasure(1, 1, A, B);
	if(K == 1) R = countTreasure(1, B, A, n);
	if(K == 2) R = countTreasure(A, 1, n, B);
	if(K == 3) R = countTreasure(A, B, n, n);
	c[K][A][B] = R;
	return R;
}

void findTreasure (int N) {
	n = N;
	for(int k=0;k<4;k++) {
		for(int i=1;i<=n;i++) {
			for(int j=1;j<=n;j++) {
				c[k][i][j] = -1;
			}
		}
	}
	aa = getc(0, n, n);
	for(int i=1;i<=n;i++) {
		if(i <= n/2) {
			px[i] = aa - getc(2, i+1, n);
			py[i] = aa - getc(1, n, i+1);
		}
		else {
			px[i] = getc(0, i, n);
			py[i] = getc(0, n, i);
		}
	}
	for(int i=1;i<=n;i++) {
		sx[i] = aa - px[i-1];
		sy[i] = aa - py[i-1];
	}
	for(int i=1;i<=n;i++) {
		for(int j=1;j<=n;j++) {
			if(i > n/2 && j > n/2) {
				a[i][j] = getc(0, i, j);
			}
			else if(i > n/2) {
				a[i][j] = getc(1, i, j+1);
				a[i][j] = px[i] - a[i][j];
			}
			else if(j > n/2) {
				a[i][j] = getc(2, i+1, j);
				a[i][j] = py[j] - a[i][j];
			}
			else {
				a[i][j] = getc(3, i+1, j+1);
				a[i][j] = px[i] - (sy[j+1] - a[i][j]);
			}
		}
	}
	for(int i=1;i<=n;i++) {
		for(int j=1;j<=n;j++) {
			if(a[i][j] - a[i-1][j] - a[i][j-1] + a[i-1][j-1]) {
				Report(i, j);
			}
		}
	}
}

Compilation message

treasure.cpp: In function 'int getc(int, int, int)':
treasure.cpp:14:13: warning: 'R' may be used uninitialized in this function [-Wmaybe-uninitialized]
  c[K][A][B] = R;
  ~~~~~~~~~~~^~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct - N = 5, K = 289, score = 10
2 Correct 2 ms 496 KB Output is correct - N = 10, K = 4475, score = 10
3 Correct 2 ms 496 KB Output is correct - N = 15, K = 22289, score = 10
4 Correct 2 ms 516 KB Output is correct - N = 16, K = 28928, score = 10
5 Correct 2 ms 664 KB Output is correct - N = 55, K = 4005289, score = 10
6 Correct 2 ms 668 KB Output is correct - N = 66, K = 8305803, score = 10
7 Correct 2 ms 668 KB Output is correct - N = 77, K = 15383161, score = 10
8 Correct 2 ms 668 KB Output is correct - N = 88, K = 26244416, score = 10
9 Correct 2 ms 680 KB Output is correct - N = 99, K = 42032201, score = 10
10 Correct 4 ms 900 KB Output is correct - N = 100, K = 43760000, score = 10