Submission #880714

#TimeUsernameProblemLanguageResultExecution timeMemory
880714MilosMilutinovicHyper-minimum (IZhO11_hyper)C++14
100 / 100
349 ms44572 KiB
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int n, m; cin >> n >> m; vector<vector<vector<vector<int>>>> a(n, vector<vector<vector<int>>>(n, vector<vector<int>>(n, vector<int>(n)))); for (int x = 0; x < n; x++) { for (int y = 0; y < n; y++) { for (int z = 0; z < n; z++) { for (int k = 0; k < n; k++) { cin >> a[x][y][z][k]; } } } } vector<vector<vector<vector<int>>>> b(n, vector<vector<vector<int>>>(n, vector<vector<int>>(n, vector<int>(n)))); for (int x = 0; x < n; x++) { for (int y = 0; y < n; y++) { for (int z = 0; z < n; z++) { deque<int> dq; for (int k = n - 1; k >= 0; k--) { while (!dq.empty() && dq.front() - k >= m) { dq.pop_front(); } while (!dq.empty() && a[x][y][z][dq.back()] >= a[x][y][z][k]) { dq.pop_back(); } b[x][y][z][k] = (dq.empty() ? a[x][y][z][k] : a[x][y][z][dq.front()]); dq.push_back(k); } } } } for (int x = 0; x < n; x++) { for (int y = 0; y < n; y++) { for (int k = 0; k <= n - m; k++) { deque<int> dq; for (int z = n - 1; z >= 0; z--) { while (!dq.empty() && dq.front() - z >= m) { dq.pop_front(); } while (!dq.empty() && b[x][y][dq.back()][k] >= b[x][y][z][k]) { dq.pop_back(); } a[x][y][z][k] = (dq.empty() ? b[x][y][z][k] : b[x][y][dq.front()][k]); dq.push_back(z); } } } } for (int x = 0; x < n; x++) { for (int k = 0; k <= n - m; k++) { for (int z = 0; z <= n - m; z++) { deque<int> dq; for (int y = n - 1; y >= 0; y--) { while (!dq.empty() && dq.front() - y >= m) { dq.pop_front(); } while (!dq.empty() && a[x][dq.back()][z][k] >= a[x][y][z][k]) { dq.pop_back(); } b[x][y][z][k] = (dq.empty() ? a[x][y][z][k] : a[x][dq.front()][z][k]); dq.push_back(y); } } } } for (int k = 0; k <= n - m; k++) { for (int z = 0; z <= n - m; z++) { for (int y = 0; y <= n - m; y++) { deque<int> dq; for (int x = n - 1; x >= 0; x--) { while (!dq.empty() && dq.front() - x >= m) { dq.pop_front(); } while (!dq.empty() && b[dq.back()][y][z][k] >= b[x][y][z][k]) { dq.pop_back(); } a[x][y][z][k] = (dq.empty() ? b[x][y][z][k] : b[dq.front()][y][z][k]); dq.push_back(x); } } } } for (int x = 0; x <= n - m; x++) { for (int y = 0; y <= n - m; y++) { for (int z = 0; z <= n - m; z++) { for (int k = 0; k <= n - m; k++) { cout << a[x][y][z][k] << " "; } } } } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...