# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
47007 | 2018-04-26T05:20:56 Z | robert | 최솟값 배열 (IZhO11_hyper) | C++14 | 854 ms | 130852 KB |
#include <cstdio> #include <queue> using namespace std; const int maxN = 36; int x[maxN][maxN][maxN][maxN]; int y[maxN][maxN][maxN][maxN]; int main(){ int N, M; scanf("%d %d", &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++){ // cout << i << " " << j << " " << k << " " << l << endl; scanf("%d", &x[i][j][k][l]); } priority_queue<pair<int, int> > mn; for(int l=N-1; l>=0; l--){ mn.push({-x[i][j][k][l], l}); while(mn.top().second>=l+M){ mn.pop(); } //top one is minimum element y[i][j][k][l] = -mn.top().first; } } for(int l=0; l<N; l++){ priority_queue<pair<int, int> > mn; for(int k=N-1; k>=0; k--){ mn.push({-y[i][j][k][l], k}); while(mn.top().second>=k+M){ mn.pop(); } y[i][j][k][l] = -mn.top().first; } } } for(int l=0; l<N; l++){ for(int k=0; k<N; k++){ priority_queue<pair<int, int> > mn; for(int j=N-1; j>=0; j--){ mn.push({-y[i][j][k][l], j}); while(mn.top().second>=j+M){ mn.pop(); } y[i][j][k][l] = -mn.top().first; } } } } // cout << "end" << endl; for(int k=0; k<N; k++){ for(int l=0; l<N; l++){ for(int j=0; j<N; j++){ priority_queue<pair<int, int>> mn; for(int i=N-1; i>=0; i--){ mn.push({-y[i][j][k][l], i}); while(mn.top().second>=i+M){ mn.pop(); } y[i][j][k][l] = -mn.top().first; } } } } for(int i=0; i<N-M+1; i++){ for(int j=0; j<N-M+1; j++){ for(int k=0; k<N-M+1; k++){ for(int l=0; l<N-M+1; l++){ if(i||j||k||l) printf(" "); printf("%d", y[i][j][k][l]); } } } } printf("\n"); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 624 KB | Output is correct |
3 | Correct | 7 ms | 1592 KB | Output is correct |
4 | Correct | 7 ms | 1692 KB | Output is correct |
5 | Correct | 7 ms | 1924 KB | Output is correct |
6 | Correct | 26 ms | 3820 KB | Output is correct |
7 | Correct | 22 ms | 4424 KB | Output is correct |
8 | Correct | 59 ms | 7752 KB | Output is correct |
9 | Correct | 95 ms | 11180 KB | Output is correct |
10 | Correct | 74 ms | 11248 KB | Output is correct |
11 | Correct | 153 ms | 18088 KB | Output is correct |
12 | Correct | 308 ms | 29732 KB | Output is correct |
13 | Correct | 282 ms | 36844 KB | Output is correct |
14 | Correct | 421 ms | 50912 KB | Output is correct |
15 | Correct | 690 ms | 70564 KB | Output is correct |
16 | Correct | 430 ms | 71360 KB | Output is correct |
17 | Correct | 508 ms | 84900 KB | Output is correct |
18 | Correct | 854 ms | 113144 KB | Output is correct |
19 | Correct | 579 ms | 117616 KB | Output is correct |
20 | Correct | 558 ms | 130852 KB | Output is correct |