# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
703032 | rainboy | Hyper-minimum (IZhO11_hyper) | C11 | 360 ms | 34596 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 <stdio.h>
#include <string.h>
#define N 35
void solve(int *aa, int n, int m) {
static int bb[N], qu[N];
int i, head, cnt;
for (i = 0, head = cnt = 0; i < n; i++) {
while (cnt && aa[qu[head + cnt - 1]] >= aa[i])
cnt--;
qu[head + cnt++] = i;
if (i >= m - 1) {
bb[i - m + 1] = aa[qu[head]];
if (qu[head] == i - m + 1)
head++, cnt--;
}
}
memcpy(aa, bb, (n - m + 1) * sizeof *bb);
}
int main() {
static int aa[N][N][N][N], bb[N];
int n, n_, m, i, j, k, l;
scanf("%d%d", &n, &m), n_ = n - m + 1;
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", &aa[i][j][k][l]);
for (i = 0; i < n; i++)
for (j = 0; j < n; j++)
for (k = 0; k < n; k++) {
for (l = 0; l < n; l++)
bb[l] = aa[i][j][k][l];
solve(bb, n, m);
for (l = 0; l < n_; l++)
aa[i][j][k][l] = bb[l];
}
for (l = 0; l < n_; l++)
for (i = 0; i < n; i++)
for (j = 0; j < n; j++) {
for (k = 0; k < n; k++)
bb[k] = aa[i][j][k][l];
solve(bb, n, m);
for (k = 0; k < n_; k++)
aa[i][j][k][l] = bb[k];
}
for (k = 0; k < n_; k++)
for (l = 0; l < n_; l++)
for (i = 0; i < n; i++) {
for (j = 0; j < n; j++)
bb[j] = aa[i][j][k][l];
solve(bb, n, m);
for (j = 0; j < n_; j++)
aa[i][j][k][l] = bb[j];
}
for (j = 0; j < n_; j++)
for (k = 0; k < n_; k++)
for (l = 0; l < n_; l++) {
for (i = 0; i < n; i++)
bb[i] = aa[i][j][k][l];
solve(bb, n, m);
for (i = 0; i < n_; i++)
aa[i][j][k][l] = bb[i];
}
for (i = 0; i < n_; i++)
for (j = 0; j < n_; j++)
for (k = 0; k < n_; k++)
for (l = 0; l < n_; l++)
printf("%d ", aa[i][j][k][l]);
printf("\n");
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |