답안 #764528

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
764528 2023-06-23T14:31:04 Z Trunkty 최솟값 배열 (IZhO11_hyper) C++14
100 / 100
497 ms 123212 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll

int n,m;
int arr[45][45][45][45],mini1[45][45][45][45],mini2[45][45][45][45],mini3[45][45][45][45],mini4[45][45][45][45];

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    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 >> arr[i][j][k][l];
                }
            }
        }
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            for(int k=1;k<=n;k++){
                multiset<int> s;
                for(int l=n;l>=1;l--){
                    if(l<=n-m){
                        s.erase(s.find(arr[i][j][k][l+m]));
                    }
                    s.insert(arr[i][j][k][l]);
                    if(l<=n-m+1LL){
                        mini1[i][j][k][l] = *s.begin();
                    }
                }
            }
        }
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            for(int k=1;k<=n;k++){
                multiset<int> s;
                for(int l=n;l>=1;l--){
                    if(l<=n-m){
                        s.erase(s.find(mini1[i][j][l+m][k]));
                    }
                    s.insert(mini1[i][j][l][k]);
                    if(l<=n-m+1LL){
                        mini2[i][j][l][k] = *s.begin();
                    }
                }
            }
        }
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            for(int k=1;k<=n;k++){
                multiset<int> s;
                for(int l=n;l>=1;l--){
                    if(l<=n-m){
                        s.erase(s.find(mini2[i][l+m][j][k]));
                    }
                    s.insert(mini2[i][l][j][k]);
                    if(l<=n-m+1LL){
                        mini3[i][l][j][k] = *s.begin();
                    }
                }
            }
        }
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            for(int k=1;k<=n;k++){
                multiset<int> s;
                for(int l=n;l>=1;l--){
                    if(l<=n-m){
                        s.erase(s.find(mini3[l+m][i][j][k]));
                    }
                    s.insert(mini3[l][i][j][k]);
                    if(l<=n-m+1LL){
                        mini4[l][i][j][k] = *s.begin();
                    }
                }
            }
        }
    }
    for(int i=1;i<=n-m+1LL;i++){
        for(int j=1;j<=n-m+1LL;j++){
            for(int k=1;k<=n-m+1LL;k++){
                for(int l=1;l<=n-m+1LL;l++){
                    cout << mini4[i][j][k][l] << " ";
                }
            }
        }
    }
    cout << "\n";
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 724 KB Output is correct
3 Correct 3 ms 2260 KB Output is correct
4 Correct 5 ms 2908 KB Output is correct
5 Correct 4 ms 3280 KB Output is correct
6 Correct 18 ms 10068 KB Output is correct
7 Correct 21 ms 8016 KB Output is correct
8 Correct 45 ms 13784 KB Output is correct
9 Correct 52 ms 25428 KB Output is correct
10 Correct 49 ms 16716 KB Output is correct
11 Correct 142 ms 36836 KB Output is correct
12 Correct 273 ms 60308 KB Output is correct
13 Correct 206 ms 40088 KB Output is correct
14 Correct 276 ms 75736 KB Output is correct
15 Correct 365 ms 106964 KB Output is correct
16 Correct 334 ms 58628 KB Output is correct
17 Correct 393 ms 78484 KB Output is correct
18 Correct 484 ms 123212 KB Output is correct
19 Correct 497 ms 93756 KB Output is correct
20 Correct 401 ms 64060 KB Output is correct