#include "minerals.h"
#include<bits/stdc++.h>
#define st first
#define nd second
#define pb push_back
#define ppb pop_back
#define ii pair<int,int>
#define ll long long
#define orta ((bas+son)>>1)
#define sz(x) ((int)x.size())
#define all(x) x.begin(),x.end()
#define umin(x,y) x=min(x,y)
#define umax(x,y) x=max(x,y)
#define inf 2000000000000000
#define N 500005
#define MOD 998244353
#define KOK 700
using namespace std;
vector<int> A,B;
vector<int> p;
vector<int> on;
int cnt;
void solve(int l,int r,vector<int> cd) {
if(l==r) {
for(auto x:cd) Answer(p[x],p[A[l]]);
return ;
}
int mid=(l+r)>>1;
if(on[l]) {
for(int i=mid+1;i<=r;i++) cnt=Query(p[A[i]]),on[i]=!on[i];
}
else {
for(int i=l;i<=mid;i++) cnt=Query(p[A[i]]),on[i]=!on[i];
}
vector<int> lcd,rcd;
for(auto x:cd) {
int cur=Query(p[x]);
if(cnt!=cur) {
rcd.pb(x);
}
else {
lcd.pb(x);
}
cnt=cur;
}
solve(l,mid,lcd);
solve(mid+1,r,rcd);
}
void Solve(int n) {
n<<=1;
mt19937 rnd(4);
on=vector<int>(n,0);
for(int i=1;i<=n;i++) p.pb(i);
shuffle(p.begin(),p.end(),rnd);
for(int i=0;i<n;i++) {
int cur=Query(p[i]);
on[i]=!on[i];
if(cur>cnt) {
A.pb(i);
}
else {
B.pb(i);
}
cnt=cur;
}
solve(0,sz(A)-1,B);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
2 ms |
248 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
248 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
376 KB |
Output is correct |
2 |
Correct |
4 ms |
504 KB |
Output is correct |
3 |
Correct |
6 ms |
632 KB |
Output is correct |
4 |
Correct |
11 ms |
760 KB |
Output is correct |
5 |
Correct |
22 ms |
1272 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
2 ms |
248 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
248 KB |
Output is correct |
5 |
Correct |
3 ms |
376 KB |
Output is correct |
6 |
Correct |
4 ms |
504 KB |
Output is correct |
7 |
Correct |
6 ms |
632 KB |
Output is correct |
8 |
Correct |
11 ms |
760 KB |
Output is correct |
9 |
Correct |
22 ms |
1272 KB |
Output is correct |
10 |
Correct |
3 ms |
376 KB |
Output is correct |
11 |
Correct |
15 ms |
1016 KB |
Output is correct |
12 |
Correct |
23 ms |
1400 KB |
Output is correct |
13 |
Correct |
22 ms |
1400 KB |
Output is correct |
14 |
Correct |
22 ms |
1272 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
2 ms |
248 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
248 KB |
Output is correct |
5 |
Correct |
3 ms |
376 KB |
Output is correct |
6 |
Correct |
4 ms |
504 KB |
Output is correct |
7 |
Correct |
6 ms |
632 KB |
Output is correct |
8 |
Correct |
11 ms |
760 KB |
Output is correct |
9 |
Correct |
22 ms |
1272 KB |
Output is correct |
10 |
Correct |
3 ms |
376 KB |
Output is correct |
11 |
Correct |
15 ms |
1016 KB |
Output is correct |
12 |
Correct |
23 ms |
1400 KB |
Output is correct |
13 |
Correct |
22 ms |
1400 KB |
Output is correct |
14 |
Correct |
22 ms |
1272 KB |
Output is correct |
15 |
Correct |
71 ms |
3112 KB |
Output is correct |
16 |
Correct |
66 ms |
3152 KB |
Output is correct |
17 |
Correct |
61 ms |
3108 KB |
Output is correct |
18 |
Correct |
65 ms |
2884 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
2 ms |
248 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
248 KB |
Output is correct |
5 |
Correct |
3 ms |
376 KB |
Output is correct |
6 |
Correct |
4 ms |
504 KB |
Output is correct |
7 |
Correct |
6 ms |
632 KB |
Output is correct |
8 |
Correct |
11 ms |
760 KB |
Output is correct |
9 |
Correct |
22 ms |
1272 KB |
Output is correct |
10 |
Correct |
3 ms |
376 KB |
Output is correct |
11 |
Correct |
15 ms |
1016 KB |
Output is correct |
12 |
Correct |
23 ms |
1400 KB |
Output is correct |
13 |
Correct |
22 ms |
1400 KB |
Output is correct |
14 |
Correct |
22 ms |
1272 KB |
Output is correct |
15 |
Correct |
71 ms |
3112 KB |
Output is correct |
16 |
Correct |
66 ms |
3152 KB |
Output is correct |
17 |
Correct |
61 ms |
3108 KB |
Output is correct |
18 |
Correct |
65 ms |
2884 KB |
Output is correct |
19 |
Correct |
67 ms |
3184 KB |
Output is correct |
20 |
Correct |
67 ms |
3200 KB |
Output is correct |
21 |
Correct |
64 ms |
3144 KB |
Output is correct |
22 |
Correct |
65 ms |
2928 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
2 ms |
248 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
248 KB |
Output is correct |
5 |
Correct |
3 ms |
376 KB |
Output is correct |
6 |
Correct |
4 ms |
504 KB |
Output is correct |
7 |
Correct |
6 ms |
632 KB |
Output is correct |
8 |
Correct |
11 ms |
760 KB |
Output is correct |
9 |
Correct |
22 ms |
1272 KB |
Output is correct |
10 |
Correct |
3 ms |
376 KB |
Output is correct |
11 |
Correct |
15 ms |
1016 KB |
Output is correct |
12 |
Correct |
23 ms |
1400 KB |
Output is correct |
13 |
Correct |
22 ms |
1400 KB |
Output is correct |
14 |
Correct |
22 ms |
1272 KB |
Output is correct |
15 |
Correct |
71 ms |
3112 KB |
Output is correct |
16 |
Correct |
66 ms |
3152 KB |
Output is correct |
17 |
Correct |
61 ms |
3108 KB |
Output is correct |
18 |
Correct |
65 ms |
2884 KB |
Output is correct |
19 |
Correct |
67 ms |
3184 KB |
Output is correct |
20 |
Correct |
67 ms |
3200 KB |
Output is correct |
21 |
Correct |
64 ms |
3144 KB |
Output is correct |
22 |
Correct |
65 ms |
2928 KB |
Output is correct |
23 |
Correct |
70 ms |
3312 KB |
Output is correct |
24 |
Correct |
69 ms |
3212 KB |
Output is correct |
25 |
Correct |
66 ms |
3184 KB |
Output is correct |
26 |
Correct |
69 ms |
3312 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
2 ms |
248 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
248 KB |
Output is correct |
5 |
Correct |
3 ms |
376 KB |
Output is correct |
6 |
Correct |
4 ms |
504 KB |
Output is correct |
7 |
Correct |
6 ms |
632 KB |
Output is correct |
8 |
Correct |
11 ms |
760 KB |
Output is correct |
9 |
Correct |
22 ms |
1272 KB |
Output is correct |
10 |
Correct |
3 ms |
376 KB |
Output is correct |
11 |
Correct |
15 ms |
1016 KB |
Output is correct |
12 |
Correct |
23 ms |
1400 KB |
Output is correct |
13 |
Correct |
22 ms |
1400 KB |
Output is correct |
14 |
Correct |
22 ms |
1272 KB |
Output is correct |
15 |
Correct |
71 ms |
3112 KB |
Output is correct |
16 |
Correct |
66 ms |
3152 KB |
Output is correct |
17 |
Correct |
61 ms |
3108 KB |
Output is correct |
18 |
Correct |
65 ms |
2884 KB |
Output is correct |
19 |
Correct |
67 ms |
3184 KB |
Output is correct |
20 |
Correct |
67 ms |
3200 KB |
Output is correct |
21 |
Correct |
64 ms |
3144 KB |
Output is correct |
22 |
Correct |
65 ms |
2928 KB |
Output is correct |
23 |
Correct |
70 ms |
3312 KB |
Output is correct |
24 |
Correct |
69 ms |
3212 KB |
Output is correct |
25 |
Correct |
66 ms |
3184 KB |
Output is correct |
26 |
Correct |
69 ms |
3312 KB |
Output is correct |
27 |
Incorrect |
69 ms |
3360 KB |
Wrong Answer [2] |
28 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
2 ms |
248 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
248 KB |
Output is correct |
5 |
Correct |
3 ms |
376 KB |
Output is correct |
6 |
Correct |
4 ms |
504 KB |
Output is correct |
7 |
Correct |
6 ms |
632 KB |
Output is correct |
8 |
Correct |
11 ms |
760 KB |
Output is correct |
9 |
Correct |
22 ms |
1272 KB |
Output is correct |
10 |
Correct |
3 ms |
376 KB |
Output is correct |
11 |
Correct |
15 ms |
1016 KB |
Output is correct |
12 |
Correct |
23 ms |
1400 KB |
Output is correct |
13 |
Correct |
22 ms |
1400 KB |
Output is correct |
14 |
Correct |
22 ms |
1272 KB |
Output is correct |
15 |
Correct |
71 ms |
3112 KB |
Output is correct |
16 |
Correct |
66 ms |
3152 KB |
Output is correct |
17 |
Correct |
61 ms |
3108 KB |
Output is correct |
18 |
Correct |
65 ms |
2884 KB |
Output is correct |
19 |
Correct |
67 ms |
3184 KB |
Output is correct |
20 |
Correct |
67 ms |
3200 KB |
Output is correct |
21 |
Correct |
64 ms |
3144 KB |
Output is correct |
22 |
Correct |
65 ms |
2928 KB |
Output is correct |
23 |
Correct |
70 ms |
3312 KB |
Output is correct |
24 |
Correct |
69 ms |
3212 KB |
Output is correct |
25 |
Correct |
66 ms |
3184 KB |
Output is correct |
26 |
Correct |
69 ms |
3312 KB |
Output is correct |
27 |
Incorrect |
69 ms |
3360 KB |
Wrong Answer [2] |
28 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
2 ms |
248 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
248 KB |
Output is correct |
5 |
Correct |
3 ms |
376 KB |
Output is correct |
6 |
Correct |
4 ms |
504 KB |
Output is correct |
7 |
Correct |
6 ms |
632 KB |
Output is correct |
8 |
Correct |
11 ms |
760 KB |
Output is correct |
9 |
Correct |
22 ms |
1272 KB |
Output is correct |
10 |
Correct |
3 ms |
376 KB |
Output is correct |
11 |
Correct |
15 ms |
1016 KB |
Output is correct |
12 |
Correct |
23 ms |
1400 KB |
Output is correct |
13 |
Correct |
22 ms |
1400 KB |
Output is correct |
14 |
Correct |
22 ms |
1272 KB |
Output is correct |
15 |
Correct |
71 ms |
3112 KB |
Output is correct |
16 |
Correct |
66 ms |
3152 KB |
Output is correct |
17 |
Correct |
61 ms |
3108 KB |
Output is correct |
18 |
Correct |
65 ms |
2884 KB |
Output is correct |
19 |
Correct |
67 ms |
3184 KB |
Output is correct |
20 |
Correct |
67 ms |
3200 KB |
Output is correct |
21 |
Correct |
64 ms |
3144 KB |
Output is correct |
22 |
Correct |
65 ms |
2928 KB |
Output is correct |
23 |
Correct |
70 ms |
3312 KB |
Output is correct |
24 |
Correct |
69 ms |
3212 KB |
Output is correct |
25 |
Correct |
66 ms |
3184 KB |
Output is correct |
26 |
Correct |
69 ms |
3312 KB |
Output is correct |
27 |
Incorrect |
69 ms |
3360 KB |
Wrong Answer [2] |
28 |
Halted |
0 ms |
0 KB |
- |