Submission #703032

#TimeUsernameProblemLanguageResultExecution timeMemory
703032rainboyHyper-minimum (IZhO11_hyper)C11
100 / 100
360 ms34596 KiB
#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)

hyper.c: In function 'main':
hyper.c:27:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   27 |  scanf("%d%d", &n, &m), n_ = n - m + 1;
      |  ^~~~~~~~~~~~~~~~~~~~~
hyper.c:32:6: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   32 |      scanf("%d", &aa[i][j][k][l]);
      |      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...