# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
334581 | iulia13 | Hyper-minimum (IZhO11_hyper) | C++14 | 1056 ms | 40760 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 |
---|---|---|---|---|
Fetching results... |