답안 #410758

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
410758 2021-05-23T15:35:05 Z maximath_1 최솟값 배열 (IZhO11_hyper) C++11
100 / 100
390 ms 59328 KB
#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

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);}
      |                       ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 716 KB Output is correct
3 Correct 3 ms 1868 KB Output is correct
4 Correct 4 ms 2348 KB Output is correct
5 Correct 5 ms 2636 KB Output is correct
6 Correct 13 ms 5900 KB Output is correct
7 Correct 10 ms 4744 KB Output is correct
8 Correct 27 ms 8080 KB Output is correct
9 Correct 60 ms 13892 KB Output is correct
10 Correct 29 ms 9164 KB Output is correct
11 Correct 90 ms 18064 KB Output is correct
12 Correct 145 ms 28260 KB Output is correct
13 Correct 121 ms 21824 KB Output is correct
14 Correct 199 ms 36292 KB Output is correct
15 Correct 313 ms 51624 KB Output is correct
16 Correct 180 ms 30032 KB Output is correct
17 Correct 207 ms 35764 KB Output is correct
18 Correct 390 ms 59328 KB Output is correct
19 Correct 261 ms 42824 KB Output is correct
20 Correct 226 ms 34140 KB Output is correct