Submission #4854

# Submission time Handle Problem Language Result Execution time Memory
4854 2014-01-05T09:52:49 Z cki86201 Hyper-minimum (IZhO11_hyper) C++
100 / 100
480 ms 24536 KB
#include<stdio.h>

int inp[4][35][35][35][35];

struct deq{
	int p[35],f,r;
	void push(int x){
		while(f!=r&&p[f-1]>x)f--;
		p[f++]=x;
	}
	void init(){f=r=0;}
	inline void pop(int x){if(p[r]==x)r++;}
	inline int read(){return p[r];}
}Dq;

int main(){
	int i,j,k,l,n,m;
	scanf("%d%d",&n,&m);
	for(i=0;i<n;i++)for(j=0;j<n;j++)for(k=0;k<n;k++)for(l=0;l<n;l++)scanf("%d",inp[0][l][i][j]+k);
	for(i=0;i<n;i++)for(j=0;j<n;j++)for(k=0;k<n;k++){
		Dq.init();
		for(l=0;l<m;l++)Dq.push(inp[0][i][j][k][l]);
		inp[1][i][j][k][m-1] = Dq.read();
		for(l=m;l<n;l++){
			Dq.pop(inp[0][i][j][k][l-m]);
			Dq.push(inp[0][i][j][k][l]);
			inp[1][i][j][k][l] = Dq.read();
		}
	}
	for(i=0;i<n;i++)for(j=0;j<n;j++)for(l=m-1;l<n;l++){
		Dq.init();
		for(k=0;k<m;k++)Dq.push(inp[1][i][j][k][l]);
		inp[2][i][j][m-1][l] = Dq.read();
		for(k=m;k<n;k++){
			Dq.pop(inp[1][i][j][k-m][l]);
			Dq.push(inp[1][i][j][k][l]);
			inp[2][i][j][k][l] = Dq.read();
		}
	}
	for(i=0;i<n;i++)for(k=m-1;k<n;k++)for(l=m-1;l<n;l++){
		Dq.init();
		for(j=0;j<m;j++)Dq.push(inp[2][i][j][k][l]);
		inp[3][i][m-1][k][l] = Dq.read();
		for(j=m;j<n;j++){
			Dq.pop(inp[2][i][j-m][k][l]);
			Dq.push(inp[2][i][j][k][l]);
			inp[3][i][j][k][l] = Dq.read();
		}
	}
	for(j=m-1;j<n;j++)for(k=m-1;k<n;k++)for(l=m-1;l<n;l++){
		Dq.init();
		for(i=0;i<m;i++)Dq.push(inp[3][i][j][k][l]);
		printf("%d ",Dq.read());
		for(i=m;i<n;i++){
			Dq.pop(inp[3][i-m][j][k][l]);
			Dq.push(inp[3][i][j][k][l]);
			printf("%d ",Dq.read());
		}
	}
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 24536 KB Output is correct
2 Correct 0 ms 24536 KB Output is correct
3 Correct 0 ms 24536 KB Output is correct
4 Correct 0 ms 24536 KB Output is correct
5 Correct 4 ms 24536 KB Output is correct
6 Correct 16 ms 24536 KB Output is correct
7 Correct 8 ms 24536 KB Output is correct
8 Correct 28 ms 24536 KB Output is correct
9 Correct 44 ms 24536 KB Output is correct
10 Correct 32 ms 24536 KB Output is correct
11 Correct 92 ms 24536 KB Output is correct
12 Correct 184 ms 24536 KB Output is correct
13 Correct 156 ms 24536 KB Output is correct
14 Correct 244 ms 24536 KB Output is correct
15 Correct 380 ms 24536 KB Output is correct
16 Correct 212 ms 24536 KB Output is correct
17 Correct 252 ms 24536 KB Output is correct
18 Correct 480 ms 24536 KB Output is correct
19 Correct 328 ms 24536 KB Output is correct
20 Correct 280 ms 24536 KB Output is correct