Submission #585484

# Submission time Handle Problem Language Result Execution time Memory
585484 2022-06-29T02:30:02 Z Shin Hyper-minimum (IZhO11_hyper) C++14
100 / 100
462 ms 37324 KB
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define all(x) x.begin(), x.end()

using namespace std;
template <class X, class Y> bool minimize(X &a, Y b) {
    if (a > b) return a = b, true;
    return false;
}
template <class X, class Y> bool maximize(X &a, Y b) {
    if (a < b) return a = b, true;
    return false;
}
 
signed main() {
  cin.tie(0)->sync_with_stdio(0);
  int n, m; cin >> n >> m;
  vector<vector<vector<vector<int>>>> a(n + 1, vector<vector<vector<int>>>(n + 1, vector<vector<int>>(n + 1, vector<int>(n + 1))));
  for (int i = 1; i <= n; i ++) {
    for (int j = 1; j <= n; j ++) {
      for (int ii = 1; ii <= n; ii ++) {
        for (int jj = 1; jj <= n; jj ++) {
          cin >> a[i][j][ii][jj];
        }
      }
    }
  }
  for (int i = 1; i <= n; i ++) {
    for (int j = 1; j <= n; j ++) {
      for (int ii = 1; ii <= n; ii ++) {
        for (int jj = 1; jj <= n; jj ++) {
          for (int k = 1; k < m; k ++) {
            if (jj + k > n) break;
            minimize(a[i][j][ii][jj], a[i][j][ii][jj + k]);
          }
        }
      }
      for (int ii = 1; ii <= n; ii ++) {
        for (int jj = 1; jj <= n; jj ++) {
          for (int k = 1; k < m; k ++) {
            if (ii + k > n) break;
            minimize(a[i][j][ii][jj], a[i][j][ii + k][jj]);
          }
        }
      }
    }
    for (int j = 1; j <= n; j ++) {
      for (int ii = 1; ii <= n; ii ++) {
        for (int jj = 1; jj <= n; jj ++) {
          for (int k = 1; k < m; k ++) {
            if (j + k > n) break;
            minimize(a[i][j][ii][jj], a[i][j + k][ii][jj]);
          }
        }
      }
    }
  }
  for (int i = 1; i <= n; i ++) {
    for (int j = 1; j <= n; j ++) {
      for (int ii = 1; ii <= n; ii ++) {
        for (int jj = 1; jj <= n; jj ++) {
          for (int k = 1; k < m; k ++) {
            if (k + i > n) break;
            minimize(a[i][j][ii][jj], a[i + k][j][ii][jj]);
          }
        }
      }
    }
  }
  for (int i = 1; i + m - 1 <= n; i ++) {
    for (int j = 1; j + m - 1 <= n; j ++) {
      for (int ii = 1; ii + m - 1 <= n; ii ++) {
        for (int jj = 1; jj + m - 1 <= n; jj ++) {
          cout << a[i][j][ii][jj] << " ";
        }
      }
    }
  }
  return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 3 ms 340 KB Output is correct
4 Correct 3 ms 340 KB Output is correct
5 Correct 2 ms 468 KB Output is correct
6 Correct 10 ms 852 KB Output is correct
7 Correct 13 ms 780 KB Output is correct
8 Correct 39 ms 1364 KB Output is correct
9 Correct 32 ms 3020 KB Output is correct
10 Correct 37 ms 1484 KB Output is correct
11 Correct 99 ms 3400 KB Output is correct
12 Correct 205 ms 14824 KB Output is correct
13 Correct 218 ms 13644 KB Output is correct
14 Correct 176 ms 19468 KB Output is correct
15 Correct 258 ms 30712 KB Output is correct
16 Correct 339 ms 19228 KB Output is correct
17 Correct 304 ms 20628 KB Output is correct
18 Correct 335 ms 37324 KB Output is correct
19 Correct 432 ms 26444 KB Output is correct
20 Correct 462 ms 24360 KB Output is correct