Submission #4543

# Submission time Handle Problem Language Result Execution time Memory
4543 2013-10-23T09:59:52 Z ainta Treasure (different grader from official contest) (CEOI13_treasure2) C++
100 / 100
0 ms 1420 KB
#include "treasure.h"
int D[4][110][110],Mid,n,w[110][110],Sx[110],Sy[110];
int mx(int a,int b){return a<b?b:a;}
int mn(int a,int b){return a<b?a:b;}
void Do(int a){
	int x,y,x1,y1,x2,y2,i,j;
	if(a<2)x=1,x1=Mid,x2=n;
	else x=n,x1=1,x2=Mid;
	if(a%2==0)y=1,y1=Mid,y2=n;
	else y=n,y1=1,y2=Mid;
	for(i=x1;i<=x2;i++){
		for(j=y1;j<=y2;j++){
			if(x+i==n+1 && y+j==n+1)continue;
			if(a==1 && j==1){D[a][i][j]=D[0][i][n];continue;}
			if(a==2 && i==1){D[a][i][j]=D[0][n][j];continue;}
			if(a==3 && i==1){D[a][i][j]=D[1][n][j];continue;}
			if(a==3 && j==1){D[a][i][j]=D[2][i][n];continue;}
			D[a][i][j]=countTreasure(mn(x,i),mn(y,j),mx(x,i),mx(y,j));
		}
	}
}
void findTreasure (int N) {
	int i,j,s;
	n=N,Mid=(N+1)/2;
	D[0][n][n]=D[1][n][1]=D[2][1][n]=D[3][1][1]=countTreasure(1,1,n,n);
	Do(0);
	Do(1);
	Do(2);
	Do(3);
	for(i=Mid+1;i<=n;i++)
		for(j=Mid+1;j<=n;j++)
			w[i][j]=(D[0][i][j]-D[0][i][j-1]) - (D[0][i-1][j]-D[0][i-1][j-1]);
	for(i=Mid+1;i<=n;i++)
		for(j=1;j<Mid;j++)
			w[i][j]=(D[1][i][j]-D[1][i][j+1]) - (D[1][i-1][j]-D[1][i-1][j+1]);
	for(i=1;i<Mid;i++)
		for(j=Mid+1;j<=n;j++)
			w[i][j]=(D[2][i][j]-D[2][i][j-1]) - (D[2][i+1][j]-D[2][i+1][j-1]);
	for(i=1;i<Mid;i++)
		for(j=1;j<Mid;j++)
			w[i][j]=(D[3][i][j]-D[3][i][j+1]) - (D[3][i+1][j]-D[3][i+1][j+1]);
	for(i=1;i<=n;i++)
		for(j=1;j<=n;j++)
			Sx[i]+=w[i][j],Sy[j]+=w[i][j];
	for(i=1;i<Mid;i++){
		w[Mid][i]=(D[3][1][i]-D[3][1][i+1])-Sy[i];
		w[i][Mid]=(D[3][i][1]-D[3][i+1][1])-Sx[i];
	}
	for(i=Mid+1;i<=n;i++){
		w[Mid][i]=(D[0][n][i]-D[0][n][i-1])-Sy[i];
		w[i][Mid]=(D[0][i][n]-D[0][i-1][n])-Sx[i];
	}
	s=0;
	for(i=1;i<=n;i++)
		for(j=1;j<=n;j++)
			s+=w[i][j];
	w[Mid][Mid]=D[0][n][n]-s;
	for(i=1;i<=n;i++)
		for(j=1;j<=n;j++)
			if(w[i][j])Report(i,j);
}

Compilation message

grader.c: In function 'int main()':
grader.c:63:34: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         my_assert(strlen(A[i]+1) == N, "each line of the map must contain N zeroes or ones (before loop)");
                                  ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 1420 KB Output is correct - N = 5, K = 289, score = 10
2 Correct 0 ms 1420 KB Output is correct - N = 10, K = 4475, score = 10
3 Correct 0 ms 1420 KB Output is correct - N = 15, K = 22289, score = 10
4 Correct 0 ms 1420 KB Output is correct - N = 16, K = 28928, score = 10
5 Correct 0 ms 1420 KB Output is correct - N = 55, K = 4005289, score = 10
6 Correct 0 ms 1420 KB Output is correct - N = 66, K = 8305803, score = 10
7 Correct 0 ms 1420 KB Output is correct - N = 77, K = 15383161, score = 10
8 Correct 0 ms 1420 KB Output is correct - N = 88, K = 26244416, score = 10
9 Correct 0 ms 1420 KB Output is correct - N = 99, K = 42032201, score = 10
10 Correct 0 ms 1420 KB Output is correct - N = 100, K = 43760000, score = 10