Submission #410758

#TimeUsernameProblemLanguageResultExecution timeMemory
410758maximath_1Hyper-minimum (IZhO11_hyper)C++11
100 / 100
390 ms59328 KiB
#include <bits/stdc++.h> #define kyou using #define mo namespace #define kawaii std kyou mo kawaii; #define ll long long #define ld long double #define endl "\n" const int MX = 2005; const int LG = (int)log2(MX) + 1; const int BLOCK = 205; const int inf = 1000000069; const ll inf_ll = 8000000000000000069ll; const ld inf_ld = (ld)inf_ll; const ld eps = 1e-9; const ll mod = 1000000007; const int alpha = 30; const int dxh[] = {1, 1, -1, -1, 2, 2, -2, -2}; const int dyh[] = {2, -2, 2, -2, 1, -1, 1, -1}; // horse const int dx[] = {1, -1, 0, 0, 0, 0}; const int dy[] = {0, 0, 1, -1, 0, 0}; // adj const int dz[] = {0, 0, 0, 0, 1, -1}; // 3d const int dxd[] = {1, 1, 1, 0, -1, -1, -1, 0}; const int dyd[] = {1, 0, -1, -1, -1, 0, 1, 1}; // diag mt19937 rng(time(NULL)); bool untied = 0; void setIn(string s){freopen(s.c_str(), "r", stdin);} void setOut(string s){freopen(s.c_str(), "w", stdout);} void unsyncIO(){cin.tie(0) -> sync_with_stdio(0);} void setIO(string s = ""){ if(!untied) unsyncIO(), untied = 1; if(s.size()){ setIn(s + ".in"); setOut(s + ".out"); } } int n, m; int v[5][36][36][36][36]; struct minqueue{ int p[100], h, t; inline void push(int x){ while(h != t && t > 0 && p[t - 1] > x) t --; p[t ++] = x; } void init() {h = t = 0;} inline void pop(int x) {if(p[h] == x) h ++;} inline int get(){return p[h];} } dq; int main(){ setIO(); cin >> n >> m; for(int i = 0; i < n; i ++) for(int j = 0; j < n; j ++) for(int k = 0; k < n; k ++) for(int l = 0; l < n; l ++) cin >> v[0][i][j][k][l]; for(int i = 0; i < n; i ++) for(int j = 0; j < n; j ++) for(int k = 0; k < n; k ++){ dq.init(); for(int l = 0; l < m; l ++) dq.push(v[0][i][j][k][l]); v[1][i][j][k][m - 1] = dq.get(); for(int l = m; l < n; l ++){ dq.pop(v[0][i][j][k][l - m]); dq.push(v[0][i][j][k][l]); v[1][i][j][k][l] = dq.get(); } } for(int i = 0; i < n; i ++) for(int j = 0; j < n; j ++) for(int l = m - 1; l < n; l ++){ dq.init(); for(int k = 0; k < m; k ++) dq.push(v[1][i][j][k][l]); v[2][i][j][m - 1][l] = dq.get(); for(int k = m; k < n; k ++){ dq.pop(v[1][i][j][k - m][l]); dq.push(v[1][i][j][k][l]); v[2][i][j][k][l] = dq.get(); } } for(int i = 0; i < n; i ++) for(int k = m - 1; k < n; k ++) for(int l = m - 1; l < n; l ++){ dq.init(); for(int j = 0; j < m; j ++) dq.push(v[2][i][j][k][l]); v[3][i][m - 1][k][l] = dq.get(); for(int j = m; j < n; j ++){ dq.pop(v[2][i][j - m][k][l]); dq.push(v[2][i][j][k][l]); v[3][i][j][k][l] = dq.get(); } } for(int j = m - 1; j < n; j ++) for(int k = m - 1; k < n; k ++) for(int l = m - 1; l < n; l ++){ dq.init(); for(int i = 0; i < m; i ++) dq.push(v[3][i][j][k][l]); v[4][m - 1][j][k][l] = dq.get(); for(int i = m; i < n; i ++){ dq.pop(v[3][i - m][j][k][l]); dq.push(v[3][i][j][k][l]); v[4][i][j][k][l] = dq.get(); } } for(int i = m - 1; i < n; i ++) for(int j = m - 1; j < n; j ++) for(int k = m - 1; k < n; k ++) for(int l = m - 1; l < n; l ++) cout << v[4][i][j][k][l] << " "; cout << endl; return 0; }

Compilation message (stderr)

hyper.cpp: In function 'void setIn(std::string)':
hyper.cpp:31:29: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   31 | void setIn(string s){freopen(s.c_str(), "r", stdin);}
      |                      ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
hyper.cpp: In function 'void setOut(std::string)':
hyper.cpp:32:30: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   32 | void setOut(string s){freopen(s.c_str(), "w", stdout);}
      |                       ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...