# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|
72161 | | @younha_holic (#118) | 박스런 (FXCUP3_box) | C++17 | | 1064 ms | 984 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#pragma optimize("O3")
using namespace std;
const int maxn = 1<<21;
int n, a[maxn], b[maxn];
int dq[maxn];
int y, z;
void xfill(int s, int e, int l, int r) {
if (s>e) return;
int m = (s+e)/2, k = max(m, l);
y = 0, z = 0;
for (int i=k-m+1; i<=k; i++) {
while (y<z and a[dq[z-1]] < a[i]) z--;
dq[z++] = i;
}
while (k+1<=r) {
if (a[k+1] > a[dq[y]]) break;
k++;
if (dq[y] < k-m+1) y++;
while (y<z and a[dq[z-1]] < a[k]) z--;
dq[z++] = k;
}
if (k>r) k = r;
b[m] = k;
if (s<e) {
xfill(s, m-1, l, k);
xfill(m+1, e, k, r);
}
}
int main() {
cin >> n;
for (int i=1; i<=n; i++) scanf("%d", &a[i]);
xfill(1, n, 1, n);
for (int i=1; i<=n; i++) {
if (b[i] == n) printf("-1 ");
else printf("%d ", b[i] - i + 1);
}
}
컴파일 시 표준 에러 (stderr) 메시지
box.cpp:2:0: warning: ignoring #pragma optimize [-Wunknown-pragmas]
#pragma optimize("O3")
box.cpp: In function 'int main()':
box.cpp:38:32: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
for (int i=1; i<=n; i++) scanf("%d", &a[i]);
~~~~~^~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |