#include <bits/stdc++.h>
#include "minerals.h"
using namespace std;
const int N = 43000 + 5;
int n, ans[N], ptr, cnt;
vector<int> a, b;
int query(int x){
return cnt = Query(x);
}
struct SegTree{
vector<int> tree[N * 4];
void build(int v = 1, int l = 1, int r = n){
if(l == r) ans[l] = tree[v].front();
else{
int m = l + (r - l) / 2;
while(ptr < m){
ptr++;
query(a[ptr - 1]);
}
while(ptr > m){
query(a[ptr - 1]);
ptr--;
}
for(auto x : tree[v]){
int prvcnt = cnt;
query(x);
if(cnt == prvcnt + 1) tree[v * 2 + 1].push_back(x);
else tree[v * 2].push_back(x);
query(x);
}
build(v * 2 + 1, m + 1, r);
build(v * 2, l, m);
}
}
};
SegTree sgt;
void Solve(int N_) {
n = N_;
for(int i = 1; i <= n * 2; i++){
int prvcnt = cnt;
query(i);
if(cnt == prvcnt + 1) a.push_back(i);
else{
query(i);
b.push_back(i);
}
}
for(auto x : a) query(x);
for(auto x : b) sgt.tree[1].push_back(x);
sgt.build();
for(int i = 1; i <= n; i++) Answer(a[i - 1], ans[i]);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
4304 KB |
Output is correct |
2 |
Correct |
2 ms |
4304 KB |
Output is correct |
3 |
Correct |
3 ms |
4304 KB |
Output is correct |
4 |
Correct |
2 ms |
4304 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
4432 KB |
Output is correct |
2 |
Correct |
3 ms |
4560 KB |
Output is correct |
3 |
Correct |
5 ms |
4816 KB |
Output is correct |
4 |
Correct |
9 ms |
5372 KB |
Output is correct |
5 |
Correct |
16 ms |
6480 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
4304 KB |
Output is correct |
2 |
Correct |
2 ms |
4304 KB |
Output is correct |
3 |
Correct |
3 ms |
4304 KB |
Output is correct |
4 |
Correct |
2 ms |
4304 KB |
Output is correct |
5 |
Correct |
3 ms |
4432 KB |
Output is correct |
6 |
Correct |
3 ms |
4560 KB |
Output is correct |
7 |
Correct |
5 ms |
4816 KB |
Output is correct |
8 |
Correct |
9 ms |
5372 KB |
Output is correct |
9 |
Correct |
16 ms |
6480 KB |
Output is correct |
10 |
Correct |
3 ms |
4432 KB |
Output is correct |
11 |
Correct |
10 ms |
6040 KB |
Output is correct |
12 |
Correct |
16 ms |
6652 KB |
Output is correct |
13 |
Correct |
13 ms |
6608 KB |
Output is correct |
14 |
Correct |
13 ms |
6532 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
4304 KB |
Output is correct |
2 |
Correct |
2 ms |
4304 KB |
Output is correct |
3 |
Correct |
3 ms |
4304 KB |
Output is correct |
4 |
Correct |
2 ms |
4304 KB |
Output is correct |
5 |
Correct |
3 ms |
4432 KB |
Output is correct |
6 |
Correct |
3 ms |
4560 KB |
Output is correct |
7 |
Correct |
5 ms |
4816 KB |
Output is correct |
8 |
Correct |
9 ms |
5372 KB |
Output is correct |
9 |
Correct |
16 ms |
6480 KB |
Output is correct |
10 |
Correct |
3 ms |
4432 KB |
Output is correct |
11 |
Correct |
10 ms |
6040 KB |
Output is correct |
12 |
Correct |
16 ms |
6652 KB |
Output is correct |
13 |
Correct |
13 ms |
6608 KB |
Output is correct |
14 |
Correct |
13 ms |
6532 KB |
Output is correct |
15 |
Incorrect |
26 ms |
8652 KB |
Wrong Answer [2] |
16 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
4304 KB |
Output is correct |
2 |
Correct |
2 ms |
4304 KB |
Output is correct |
3 |
Correct |
3 ms |
4304 KB |
Output is correct |
4 |
Correct |
2 ms |
4304 KB |
Output is correct |
5 |
Correct |
3 ms |
4432 KB |
Output is correct |
6 |
Correct |
3 ms |
4560 KB |
Output is correct |
7 |
Correct |
5 ms |
4816 KB |
Output is correct |
8 |
Correct |
9 ms |
5372 KB |
Output is correct |
9 |
Correct |
16 ms |
6480 KB |
Output is correct |
10 |
Correct |
3 ms |
4432 KB |
Output is correct |
11 |
Correct |
10 ms |
6040 KB |
Output is correct |
12 |
Correct |
16 ms |
6652 KB |
Output is correct |
13 |
Correct |
13 ms |
6608 KB |
Output is correct |
14 |
Correct |
13 ms |
6532 KB |
Output is correct |
15 |
Incorrect |
26 ms |
8652 KB |
Wrong Answer [2] |
16 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
4304 KB |
Output is correct |
2 |
Correct |
2 ms |
4304 KB |
Output is correct |
3 |
Correct |
3 ms |
4304 KB |
Output is correct |
4 |
Correct |
2 ms |
4304 KB |
Output is correct |
5 |
Correct |
3 ms |
4432 KB |
Output is correct |
6 |
Correct |
3 ms |
4560 KB |
Output is correct |
7 |
Correct |
5 ms |
4816 KB |
Output is correct |
8 |
Correct |
9 ms |
5372 KB |
Output is correct |
9 |
Correct |
16 ms |
6480 KB |
Output is correct |
10 |
Correct |
3 ms |
4432 KB |
Output is correct |
11 |
Correct |
10 ms |
6040 KB |
Output is correct |
12 |
Correct |
16 ms |
6652 KB |
Output is correct |
13 |
Correct |
13 ms |
6608 KB |
Output is correct |
14 |
Correct |
13 ms |
6532 KB |
Output is correct |
15 |
Incorrect |
26 ms |
8652 KB |
Wrong Answer [2] |
16 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
4304 KB |
Output is correct |
2 |
Correct |
2 ms |
4304 KB |
Output is correct |
3 |
Correct |
3 ms |
4304 KB |
Output is correct |
4 |
Correct |
2 ms |
4304 KB |
Output is correct |
5 |
Correct |
3 ms |
4432 KB |
Output is correct |
6 |
Correct |
3 ms |
4560 KB |
Output is correct |
7 |
Correct |
5 ms |
4816 KB |
Output is correct |
8 |
Correct |
9 ms |
5372 KB |
Output is correct |
9 |
Correct |
16 ms |
6480 KB |
Output is correct |
10 |
Correct |
3 ms |
4432 KB |
Output is correct |
11 |
Correct |
10 ms |
6040 KB |
Output is correct |
12 |
Correct |
16 ms |
6652 KB |
Output is correct |
13 |
Correct |
13 ms |
6608 KB |
Output is correct |
14 |
Correct |
13 ms |
6532 KB |
Output is correct |
15 |
Incorrect |
26 ms |
8652 KB |
Wrong Answer [2] |
16 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
4304 KB |
Output is correct |
2 |
Correct |
2 ms |
4304 KB |
Output is correct |
3 |
Correct |
3 ms |
4304 KB |
Output is correct |
4 |
Correct |
2 ms |
4304 KB |
Output is correct |
5 |
Correct |
3 ms |
4432 KB |
Output is correct |
6 |
Correct |
3 ms |
4560 KB |
Output is correct |
7 |
Correct |
5 ms |
4816 KB |
Output is correct |
8 |
Correct |
9 ms |
5372 KB |
Output is correct |
9 |
Correct |
16 ms |
6480 KB |
Output is correct |
10 |
Correct |
3 ms |
4432 KB |
Output is correct |
11 |
Correct |
10 ms |
6040 KB |
Output is correct |
12 |
Correct |
16 ms |
6652 KB |
Output is correct |
13 |
Correct |
13 ms |
6608 KB |
Output is correct |
14 |
Correct |
13 ms |
6532 KB |
Output is correct |
15 |
Incorrect |
26 ms |
8652 KB |
Wrong Answer [2] |
16 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
4304 KB |
Output is correct |
2 |
Correct |
2 ms |
4304 KB |
Output is correct |
3 |
Correct |
3 ms |
4304 KB |
Output is correct |
4 |
Correct |
2 ms |
4304 KB |
Output is correct |
5 |
Correct |
3 ms |
4432 KB |
Output is correct |
6 |
Correct |
3 ms |
4560 KB |
Output is correct |
7 |
Correct |
5 ms |
4816 KB |
Output is correct |
8 |
Correct |
9 ms |
5372 KB |
Output is correct |
9 |
Correct |
16 ms |
6480 KB |
Output is correct |
10 |
Correct |
3 ms |
4432 KB |
Output is correct |
11 |
Correct |
10 ms |
6040 KB |
Output is correct |
12 |
Correct |
16 ms |
6652 KB |
Output is correct |
13 |
Correct |
13 ms |
6608 KB |
Output is correct |
14 |
Correct |
13 ms |
6532 KB |
Output is correct |
15 |
Incorrect |
26 ms |
8652 KB |
Wrong Answer [2] |
16 |
Halted |
0 ms |
0 KB |
- |