Submission #523199

#TimeUsernameProblemLanguageResultExecution timeMemory
523199redstonegamer22Hyper-minimum (IZhO11_hyper)C++17
100 / 100
1014 ms48756 KiB
#include <bits/stdc++.h> using namespace std; const int NMAX = 40; int x[NMAX][NMAX][NMAX][NMAX]; int y[NMAX][NMAX][NMAX][NMAX]; void print_x(ostream& out, int n) { for(int i = 1; i <= n; i++) { for(int j = 1; j <= n; j++) { for(int k = 1; k <= n; k++) { for(int l = 1; l <= n; l++) { out << x[i][j][k][l] << " "; } } } } out << endl; } int main() { assert(NMAX * NMAX * NMAX * NMAX > 1500000); int n, m; cin >> n >> m; for(int i = 1; i <= n; i++) for(int j = 1; j <= n; j++) for(int k = 1; k <= n; k++) for(int l = 1; l <= n; l++) cin >> x[i][j][k][l]; /// Compress l memset(y, 0x7F, sizeof(y)); for(int i = 1; i <= n; i++) { for(int j = 1; j <= n; j++) { for(int k = 1; k <= n; k++) { multiset<int> ms; for(int l = 1; l <= n; l++) { ms.insert(x[i][j][k][l]); if(l - m >= 1) ms.erase(ms.find(x[i][j][k][l - m])); if(l - m + 1 >= 1) y[i][j][k][l - m + 1] = *(ms.begin()); } } } } memcpy(x, y, sizeof(x)); #ifdef LOCAL print_x(cerr, n); #endif // LOCAL /// Compress k memset(y, 0x7F, sizeof(y)); for(int i = 1; i <= n; i++) { for(int j = 1; j <= n; j++) { for(int l = 1; l <= n; l++) { multiset<int> ms; for(int k = 1; k <= n; k++) { ms.insert(x[i][j][k][l]); if(k - m >= 1) ms.erase(ms.find(x[i][j][k - m][l])); if(k - m + 1 >= 1) y[i][j][k - m + 1][l] = *(ms.begin()); } } } } memcpy(x, y, sizeof(x)); #ifdef LOCAL print_x(cerr, n); #endif // LOCAL /// Compress j memset(y, 0x7F, sizeof(y)); for(int i = 1; i <= n; i++) { for(int k = 1; k <= n; k++) { for(int l = 1; l <= n; l++) { multiset<int> ms; for(int j = 1; j <= n; j++) { ms.insert(x[i][j][k][l]); if(j - m >= 1) ms.erase(ms.find(x[i][j - m][k][l])); if(j - m + 1 >= 1) y[i][j - m + 1][k][l] = *(ms.begin()); } } } } memcpy(x, y, sizeof(x)); #ifdef LOCAL print_x(cerr, n); #endif // LOCAL /// Compress i memset(y, 0x7F, sizeof(y)); for(int j = 1; j <= n; j++) { for(int k = 1; k <= n; k++) { for(int l = 1; l <= n; l++) { multiset<int> ms; for(int i = 1; i <= n; i++) { ms.insert(x[i][j][k][l]); if(i - m >= 1) ms.erase(ms.find(x[i - m][j][k][l])); if(i - m + 1 >= 1) y[i - m + 1][j][k][l] = *(ms.begin()); } } } } memcpy(x, y, sizeof(x)); #ifdef LOCAL print_x(cerr, n); #endif // LOCAL print_x(cout, n - m + 1); }
#Verdict Execution timeMemoryGrader output
Fetching results...