Submission #47007

#TimeUsernameProblemLanguageResultExecution timeMemory
47007robertHyper-minimum (IZhO11_hyper)C++14
100 / 100
854 ms130852 KiB
#include <cstdio>
#include <queue>

using namespace std;

const int maxN = 36;
int x[maxN][maxN][maxN][maxN];
int y[maxN][maxN][maxN][maxN];

int main(){
	int N, M; scanf("%d %d", &N, &M);
	
	for(int i=0; i<N; i++){
		for(int j=0; j<N; j++){
			for(int k=0; k<N; k++){
				for(int l=0; l<N; l++){
				//	cout << i << " " << j << " " << k << " " << l << endl;
					scanf("%d", &x[i][j][k][l]);
				}
				priority_queue<pair<int, int> > mn;
				for(int l=N-1; l>=0; l--){
					mn.push({-x[i][j][k][l], l});
					while(mn.top().second>=l+M){
						mn.pop();
					}
					//top one is minimum element
					y[i][j][k][l] = -mn.top().first;
				}
			}
			for(int l=0; l<N; l++){
				priority_queue<pair<int, int> > mn;
				for(int k=N-1; k>=0; k--){
						mn.push({-y[i][j][k][l], k});
						while(mn.top().second>=k+M){
							mn.pop();
						}
						y[i][j][k][l] = -mn.top().first;
				}
			}
		}
		for(int l=0; l<N; l++){
			for(int k=0; k<N; k++){
				priority_queue<pair<int, int> > mn;
				for(int j=N-1; j>=0; j--){
					mn.push({-y[i][j][k][l], j});
					while(mn.top().second>=j+M){
						mn.pop();
					}
					y[i][j][k][l] = -mn.top().first;
				}
			}
		}
	}
//	cout << "end" << endl;
	for(int k=0; k<N; k++){
		for(int l=0; l<N; l++){
			for(int j=0; j<N; j++){
				priority_queue<pair<int, int>> mn;
				for(int i=N-1; i>=0; i--){
					mn.push({-y[i][j][k][l], i});
					while(mn.top().second>=i+M){
						mn.pop();
					}
					y[i][j][k][l] = -mn.top().first;
				}
			}
		}
	}
	for(int i=0; i<N-M+1; i++){
		for(int j=0; j<N-M+1; j++){
			for(int k=0; k<N-M+1; k++){
				for(int l=0; l<N-M+1; l++){
					if(i||j||k||l)
						printf(" ");
					printf("%d", y[i][j][k][l]);
				}
			}
		}
	}
	printf("\n");
	return 0;
}

Compilation message (stderr)

hyper.cpp: In function 'int main()':
hyper.cpp:11:17: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  int N, M; scanf("%d %d", &N, &M);
            ~~~~~^~~~~~~~~~~~~~~~~
hyper.cpp:18:11: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
      scanf("%d", &x[i][j][k][l]);
      ~~~~~^~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...