#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;
bool tol=0,tor=0;
for(auto x:cd) {
if(tol) {lcd.pb(x);continue ;}
if(tor) {rcd.pb(x);continue ;}
int cur=Query(p[x]);
if(cnt!=cur) {
rcd.pb(x);
}
else {
lcd.pb(x);
}
cnt=cur;
if(sz(lcd)==mid-l+1) tor=1;
if(sz(rcd)==r-mid) tol=1;
}
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);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
248 KB |
Output is correct |
4 |
Correct |
2 ms |
248 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
376 KB |
Output is correct |
2 |
Correct |
4 ms |
376 KB |
Output is correct |
3 |
Correct |
6 ms |
504 KB |
Output is correct |
4 |
Correct |
11 ms |
760 KB |
Output is correct |
5 |
Correct |
23 ms |
1400 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
248 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 |
376 KB |
Output is correct |
7 |
Correct |
6 ms |
504 KB |
Output is correct |
8 |
Correct |
11 ms |
760 KB |
Output is correct |
9 |
Correct |
23 ms |
1400 KB |
Output is correct |
10 |
Correct |
4 ms |
376 KB |
Output is correct |
11 |
Correct |
15 ms |
1144 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 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
248 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 |
376 KB |
Output is correct |
7 |
Correct |
6 ms |
504 KB |
Output is correct |
8 |
Correct |
11 ms |
760 KB |
Output is correct |
9 |
Correct |
23 ms |
1400 KB |
Output is correct |
10 |
Correct |
4 ms |
376 KB |
Output is correct |
11 |
Correct |
15 ms |
1144 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 |
75 ms |
3124 KB |
Output is correct |
16 |
Correct |
68 ms |
3120 KB |
Output is correct |
17 |
Correct |
63 ms |
3056 KB |
Output is correct |
18 |
Correct |
66 ms |
3056 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
248 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 |
376 KB |
Output is correct |
7 |
Correct |
6 ms |
504 KB |
Output is correct |
8 |
Correct |
11 ms |
760 KB |
Output is correct |
9 |
Correct |
23 ms |
1400 KB |
Output is correct |
10 |
Correct |
4 ms |
376 KB |
Output is correct |
11 |
Correct |
15 ms |
1144 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 |
75 ms |
3124 KB |
Output is correct |
16 |
Correct |
68 ms |
3120 KB |
Output is correct |
17 |
Correct |
63 ms |
3056 KB |
Output is correct |
18 |
Correct |
66 ms |
3056 KB |
Output is correct |
19 |
Correct |
68 ms |
3260 KB |
Output is correct |
20 |
Correct |
69 ms |
3180 KB |
Output is correct |
21 |
Correct |
64 ms |
3184 KB |
Output is correct |
22 |
Correct |
66 ms |
3128 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
248 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 |
376 KB |
Output is correct |
7 |
Correct |
6 ms |
504 KB |
Output is correct |
8 |
Correct |
11 ms |
760 KB |
Output is correct |
9 |
Correct |
23 ms |
1400 KB |
Output is correct |
10 |
Correct |
4 ms |
376 KB |
Output is correct |
11 |
Correct |
15 ms |
1144 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 |
75 ms |
3124 KB |
Output is correct |
16 |
Correct |
68 ms |
3120 KB |
Output is correct |
17 |
Correct |
63 ms |
3056 KB |
Output is correct |
18 |
Correct |
66 ms |
3056 KB |
Output is correct |
19 |
Correct |
68 ms |
3260 KB |
Output is correct |
20 |
Correct |
69 ms |
3180 KB |
Output is correct |
21 |
Correct |
64 ms |
3184 KB |
Output is correct |
22 |
Correct |
66 ms |
3128 KB |
Output is correct |
23 |
Correct |
70 ms |
3252 KB |
Output is correct |
24 |
Correct |
72 ms |
3312 KB |
Output is correct |
25 |
Correct |
67 ms |
3228 KB |
Output is correct |
26 |
Correct |
67 ms |
3040 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
248 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 |
376 KB |
Output is correct |
7 |
Correct |
6 ms |
504 KB |
Output is correct |
8 |
Correct |
11 ms |
760 KB |
Output is correct |
9 |
Correct |
23 ms |
1400 KB |
Output is correct |
10 |
Correct |
4 ms |
376 KB |
Output is correct |
11 |
Correct |
15 ms |
1144 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 |
75 ms |
3124 KB |
Output is correct |
16 |
Correct |
68 ms |
3120 KB |
Output is correct |
17 |
Correct |
63 ms |
3056 KB |
Output is correct |
18 |
Correct |
66 ms |
3056 KB |
Output is correct |
19 |
Correct |
68 ms |
3260 KB |
Output is correct |
20 |
Correct |
69 ms |
3180 KB |
Output is correct |
21 |
Correct |
64 ms |
3184 KB |
Output is correct |
22 |
Correct |
66 ms |
3128 KB |
Output is correct |
23 |
Correct |
70 ms |
3252 KB |
Output is correct |
24 |
Correct |
72 ms |
3312 KB |
Output is correct |
25 |
Correct |
67 ms |
3228 KB |
Output is correct |
26 |
Correct |
67 ms |
3040 KB |
Output is correct |
27 |
Correct |
74 ms |
3300 KB |
Output is correct |
28 |
Correct |
73 ms |
3312 KB |
Output is correct |
29 |
Correct |
71 ms |
3228 KB |
Output is correct |
30 |
Correct |
71 ms |
3056 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
248 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 |
376 KB |
Output is correct |
7 |
Correct |
6 ms |
504 KB |
Output is correct |
8 |
Correct |
11 ms |
760 KB |
Output is correct |
9 |
Correct |
23 ms |
1400 KB |
Output is correct |
10 |
Correct |
4 ms |
376 KB |
Output is correct |
11 |
Correct |
15 ms |
1144 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 |
75 ms |
3124 KB |
Output is correct |
16 |
Correct |
68 ms |
3120 KB |
Output is correct |
17 |
Correct |
63 ms |
3056 KB |
Output is correct |
18 |
Correct |
66 ms |
3056 KB |
Output is correct |
19 |
Correct |
68 ms |
3260 KB |
Output is correct |
20 |
Correct |
69 ms |
3180 KB |
Output is correct |
21 |
Correct |
64 ms |
3184 KB |
Output is correct |
22 |
Correct |
66 ms |
3128 KB |
Output is correct |
23 |
Correct |
70 ms |
3252 KB |
Output is correct |
24 |
Correct |
72 ms |
3312 KB |
Output is correct |
25 |
Correct |
67 ms |
3228 KB |
Output is correct |
26 |
Correct |
67 ms |
3040 KB |
Output is correct |
27 |
Correct |
74 ms |
3300 KB |
Output is correct |
28 |
Correct |
73 ms |
3312 KB |
Output is correct |
29 |
Correct |
71 ms |
3228 KB |
Output is correct |
30 |
Correct |
71 ms |
3056 KB |
Output is correct |
31 |
Correct |
74 ms |
3296 KB |
Output is correct |
32 |
Correct |
75 ms |
3400 KB |
Output is correct |
33 |
Correct |
70 ms |
3312 KB |
Output is correct |
34 |
Correct |
74 ms |
3116 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
248 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 |
376 KB |
Output is correct |
7 |
Correct |
6 ms |
504 KB |
Output is correct |
8 |
Correct |
11 ms |
760 KB |
Output is correct |
9 |
Correct |
23 ms |
1400 KB |
Output is correct |
10 |
Correct |
4 ms |
376 KB |
Output is correct |
11 |
Correct |
15 ms |
1144 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 |
75 ms |
3124 KB |
Output is correct |
16 |
Correct |
68 ms |
3120 KB |
Output is correct |
17 |
Correct |
63 ms |
3056 KB |
Output is correct |
18 |
Correct |
66 ms |
3056 KB |
Output is correct |
19 |
Correct |
68 ms |
3260 KB |
Output is correct |
20 |
Correct |
69 ms |
3180 KB |
Output is correct |
21 |
Correct |
64 ms |
3184 KB |
Output is correct |
22 |
Correct |
66 ms |
3128 KB |
Output is correct |
23 |
Correct |
70 ms |
3252 KB |
Output is correct |
24 |
Correct |
72 ms |
3312 KB |
Output is correct |
25 |
Correct |
67 ms |
3228 KB |
Output is correct |
26 |
Correct |
67 ms |
3040 KB |
Output is correct |
27 |
Correct |
74 ms |
3300 KB |
Output is correct |
28 |
Correct |
73 ms |
3312 KB |
Output is correct |
29 |
Correct |
71 ms |
3228 KB |
Output is correct |
30 |
Correct |
71 ms |
3056 KB |
Output is correct |
31 |
Correct |
74 ms |
3296 KB |
Output is correct |
32 |
Correct |
75 ms |
3400 KB |
Output is correct |
33 |
Correct |
70 ms |
3312 KB |
Output is correct |
34 |
Correct |
74 ms |
3116 KB |
Output is correct |
35 |
Incorrect |
75 ms |
3440 KB |
Wrong Answer [2] |
36 |
Halted |
0 ms |
0 KB |
- |