Submission #2706019
Source Code Expand
#include <bits/stdc++.h>
using namespace std;
struct N {
int v, l, x, y, r;
};
bool operator<(const N &a, const N &b) {
return a.v > b.v;
}
priority_queue<N> q;
int n, a[100020];
pair<int, int> f[200020][17];
pair<int, int> Q(int x, int y) {
int l = 31 - __builtin_clz(y - x);
return min(f[x][l], f[y - (1 << l)][l]);
}
void push(int l, int r) {
if (l == r) {
return;
}
pair<int, int> x = Q(l, r);
pair<int, int> y = Q(x.second + 1, r + 1);
q.push({x.first, l, x.second, y.second, r});
}
int main() {
scanf("%d", &n);
for (int i = 0; i < n; i++) {
scanf("%d", &a[i]);
f[i][1] = make_pair(a[i], i);
}
for (int j = 1; j < 16; j++) {
for (int i = 0; i < n; i++) {
f[i][j + 1] = min(f[i][j], f[i + (1 << j)][j]);
}
}
push(0, n);
for (int i = 0; i < n; i += 2) {
N u = q.top();
q.pop();
printf("%d %d ", a[u.x], a[u.y]);
push(u.l, u.x);
push(u.x + 1, u.y);
push(u.y + 1, u.r);
}
return 0;
}
Submission Info
Submission Time |
|
Task |
E - Young Maids |
User |
Factorio |
Language |
C++14 (GCC 5.4.1) |
Score |
0 |
Code Size |
974 Byte |
Status |
RE |
Exec Time |
126 ms |
Memory |
17852 KB |
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:25:17: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d", &n);
^
./Main.cpp:27:21: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d", &a[i]);
^
Judge Result
Set Name |
Sample |
All |
Score / Max Score |
0 / 0 |
0 / 800 |
Status |
|
|
Set Name |
Test Cases |
Sample |
0_00.txt, 0_01.txt, 0_02.txt |
All |
0_00.txt, 0_01.txt, 0_02.txt, 1_00.txt, 1_01.txt, 1_02.txt, 1_03.txt, 1_04.txt, 1_05.txt, 1_06.txt, 1_07.txt, 1_08.txt, 1_09.txt, 1_10.txt, 1_11.txt, 1_12.txt, 1_13.txt, 1_14.txt, 1_15.txt, 1_16.txt, 1_17.txt, 1_18.txt, 1_19.txt |
Case Name |
Status |
Exec Time |
Memory |
0_00.txt |
AC |
2 ms |
2304 KB |
0_01.txt |
AC |
2 ms |
2304 KB |
0_02.txt |
AC |
2 ms |
2304 KB |
1_00.txt |
AC |
2 ms |
2304 KB |
1_01.txt |
AC |
2 ms |
2304 KB |
1_02.txt |
RE |
125 ms |
17536 KB |
1_03.txt |
RE |
121 ms |
17152 KB |
1_04.txt |
RE |
111 ms |
16896 KB |
1_05.txt |
RE |
119 ms |
17376 KB |
1_06.txt |
RE |
112 ms |
16896 KB |
1_07.txt |
RE |
113 ms |
16896 KB |
1_08.txt |
RE |
111 ms |
16896 KB |
1_09.txt |
RE |
126 ms |
17280 KB |
1_10.txt |
RE |
112 ms |
16896 KB |
1_11.txt |
RE |
111 ms |
16896 KB |
1_12.txt |
RE |
116 ms |
17280 KB |
1_13.txt |
RE |
110 ms |
16896 KB |
1_14.txt |
RE |
111 ms |
16896 KB |
1_15.txt |
RE |
112 ms |
16896 KB |
1_16.txt |
WA |
29 ms |
17596 KB |
1_17.txt |
WA |
37 ms |
17852 KB |
1_18.txt |
RE |
110 ms |
16896 KB |
1_19.txt |
RE |
111 ms |
17024 KB |