# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
4853 | tncks0121 | Hyper-minimum (IZhO11_hyper) | C++98 | 532 ms | 123308 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.
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <string>
#include <functional>
#include <vector>
#include <deque>
#include <utility>
#include <bitset>
#include <limits.h>
#include <time.h>
using namespace std;
typedef long long ll;
typedef unsigned long long llu;
typedef double lf;
typedef unsigned int uint;
typedef long double llf;
typedef pair<int, int> pii;
#define FOR1(i, s, e) for(int i = (s); i <= (e); i++)
#define FOR2(i, j, s, e) FOR1(i, s, e) FOR1(j, s, e)
#define FOR3(i, j, k, s, e) FOR1(i, s, e) FOR1(j, s, e) FOR1(k, s, e)
#define FOR4(i, j, k, l, s, e) FOR1(i, s, e) FOR1(j, s, e) FOR1(k, s, e) FOR1(l, s, e)
int N, M, K;
int X[50][50][50][50];
int R1[50][50][50][50];
int R2[50][50][50][50];
int R3[50][50][50][50];
int R4[50][50][50][50];
int tmp1[50], tmp2[50];
deque<pii> deq;
void fillmin (int *to, int *A) {
while(!deq.empty()) deq.pop_back();
FOR1(i, 1, N) {
while(!deq.empty() && deq.back().first > A[i]) deq.pop_back();
deq.push_back(pii(A[i], i));
while(!deq.empty() && deq.front().second <= i-M) deq.pop_front();
if(i >= M) to[i-M+1] = deq.front().first;
}
}
int main() {
int i, j, k;
scanf("%d%d", &N, &M);
FOR4(i1, i2, i3, i4, 1, N) scanf("%d", &X[i1][i2][i3][i4]);
K = N-M+1;
FOR3(i1, i2, i3, 1, N) {
fillmin(R1[i1][i2][i3], X[i1][i2][i3]);
}
FOR2(i1, i2, 1, N) FOR1(i4, 1, K) {
FOR1(i3, 1, N) tmp1[i3] = R1[i1][i2][i3][i4];
fillmin(tmp2, tmp1);
FOR1(i3, 1, K) R2[i1][i2][i3][i4] = tmp2[i3];
}
FOR1(i1, 1, N) FOR2(i3, i4, 1, K) {
FOR1(i2, 1, N) tmp1[i2] = R2[i1][i2][i3][i4];
fillmin(tmp2, tmp1);
FOR1(i2, 1, K) R3[i1][i2][i3][i4] = tmp2[i2];
}
FOR3(i2, i3, i4, 1, K) {
FOR1(i1, 1, N) tmp1[i1] = R3[i1][i2][i3][i4];
fillmin(tmp2, tmp1);
FOR1(i1, 1, K) R4[i1][i2][i3][i4] = tmp2[i1];
}
FOR4(i1, i2, i3, i4, 1, K) printf("%d ", R4[i1][i2][i3][i4]);
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |