Submission #334581

# Submission time Handle Problem Language Result Execution time Memory
334581 2020-12-09T13:06:02 Z iulia13 Hyper-minimum (IZhO11_hyper) C++14
100 / 100
1056 ms 40760 KB
#include <iostream>
#include <deque>
using namespace std;
int a[50][50][50][50];
int b[50][50][50][50];
struct ura{
    int p, v;
};
deque <ura> dq;
void del()
{
    while (!dq.empty())
        dq.pop_back();
}
void scot1(int ind)
{
    while (!dq.empty() and dq.front().p < ind)
        dq.pop_front();
}
void scot2(int val, int poz)
{
    while (!dq.empty() and dq.back().v >= val)
        dq.pop_back();
}
int main()
{
    int n, m, i, j, k, l;
    cin >> n >> m;
    for (i = 1; i <= n; i++)
        for (j = 1; j <= n; j++)
            for (k = 1; k <= n; k++)
                for (l = 1; l <= n; l++)
                    cin >> a[i][j][k][l];
    for (i = 1; i <= n; i++)
        for (j = 1; j <= n; j++)
            for (k = 1; k <= n; k++)
            {
                del();
                for (l = 1; l <= n; l++)
                {
                    if (l >= m)
                        scot1(l - m + 1);
                    scot2(a[i][j][k][l], l);
                    dq.push_back({l, a[i][j][k][l]});
                    if (l >= m)
                        a[i][j][k][l - m + 1] = dq.front().v;
                }
            }
    for (i = 1; i <= n; i++)
        for (j = 1; j <= n; j++)
            for (l = 1; l <= n - m + 1; l++)
            {
                del();
                for (k = 1; k <= n; k++)
                {
                    if (k >= m)
                        scot1(k - m + 1);
                    scot2(a[i][j][k][l], k);
                    dq.push_back({k, a[i][j][k][l]});
                    if (k >= m)
                        a[i][j][k - m + 1][l] = dq.front().v;
                }
            }
    for (i = 1; i <= n; i++)
        for (k = 1; k <= n - m + 1; k++)
            for (l = 1; l <= n - m + 1; l++)
            {
                del();
                for (j = 1; j <= n; j++)
                {
                    if (j >= m)
                        scot1(j - m + 1);
                    scot2(a[i][j][k][l], j);
                    dq.push_back({j, a[i][j][k][l]});
                    if (j >= m)
                        a[i][j - m + 1][k][l] = dq.front().v;
                }
            }
     for (j = 1; j <= n - m + 1; j++)
        for (k = 1; k <= n - m + 1; k++)
            for (l = 1; l <= n - m + 1; l++)
            {
                del();
                for (i = 1; i <= n; i++)
                {
                    if (i >= m)
                        scot1(i - m + 1);
                    scot2(a[i][j][k][l], i);
                    dq.push_back({i, a[i][j][k][l]});
                    if (i >= m)
                        a[i - m + 1][j][k][l] = dq.front().v;
                }
            }
    for (i = 1; i <= n - m + 1; i++)
        for (j = 1; j <= n - m + 1; j++)
            for (k = 1; k <= n - m + 1; k++)
                for (l = 1; l <= n - m + 1; l++)
                    cout << a[i][j][k][l] << " ";
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 512 KB Output is correct
3 Correct 6 ms 1004 KB Output is correct
4 Correct 8 ms 1004 KB Output is correct
5 Correct 7 ms 1132 KB Output is correct
6 Correct 32 ms 2540 KB Output is correct
7 Correct 27 ms 2416 KB Output is correct
8 Correct 84 ms 5104 KB Output is correct
9 Correct 126 ms 6760 KB Output is correct
10 Correct 86 ms 5200 KB Output is correct
11 Correct 217 ms 10604 KB Output is correct
12 Correct 436 ms 18620 KB Output is correct
13 Correct 412 ms 17388 KB Output is correct
14 Correct 510 ms 23304 KB Output is correct
15 Correct 789 ms 34668 KB Output is correct
16 Correct 634 ms 23148 KB Output is correct
17 Correct 615 ms 24540 KB Output is correct
18 Correct 1056 ms 40760 KB Output is correct
19 Correct 838 ms 29828 KB Output is correct
20 Correct 733 ms 27628 KB Output is correct