# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
47007 | robert | Hyper-minimum (IZhO11_hyper) | C++14 | 854 ms | 130852 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |