#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;
mt19937 rnd;
void make(int l,int mid,int r) {
for(int i=l;i<=mid;i++) {
if(!on[i]) cnt=Query(p[A[i]]),on[i]=!on[i];
}
for(int i=mid+1;i<=r;i++) {
if(on[i]) cnt=Query(p[A[i]]),on[i]=!on[i];
}
}
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;
make(l,mid,r);
vector<int> lcd,rcd;
bool tol=0,tor=0;
shuffle(cd.begin(),cd.end(),rnd);
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;
rnd=mt19937(time(NULL));
on=vector<int>(n,0);
for(int i=1;i<=n;i++) p.pb(i);
shuffle(p.begin(),p.end(),rnd);
bool toA=0,toB=0;
for(int i=0;i<n;i++) {
if(toA) {A.pb(i);continue ;}
if(toB) {B.pb(i);continue ;}
int cur=Query(p[i]);
on[i]=!on[i];
if(cur>cnt) {
A.pb(i);
}
else {
B.pb(i);
}
if(sz(A)==n/2) toB=1;
if(sz(B)==n/2) toA=1;
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 |
248 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
420 KB |
Output is correct |
2 |
Correct |
5 ms |
424 KB |
Output is correct |
3 |
Correct |
8 ms |
504 KB |
Output is correct |
4 |
Correct |
16 ms |
760 KB |
Output is correct |
5 |
Correct |
29 ms |
1400 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 |
248 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
3 ms |
420 KB |
Output is correct |
6 |
Correct |
5 ms |
424 KB |
Output is correct |
7 |
Correct |
8 ms |
504 KB |
Output is correct |
8 |
Correct |
16 ms |
760 KB |
Output is correct |
9 |
Correct |
29 ms |
1400 KB |
Output is correct |
10 |
Correct |
3 ms |
376 KB |
Output is correct |
11 |
Correct |
19 ms |
1064 KB |
Output is correct |
12 |
Correct |
33 ms |
1344 KB |
Output is correct |
13 |
Correct |
43 ms |
1372 KB |
Output is correct |
14 |
Correct |
31 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 |
248 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
3 ms |
420 KB |
Output is correct |
6 |
Correct |
5 ms |
424 KB |
Output is correct |
7 |
Correct |
8 ms |
504 KB |
Output is correct |
8 |
Correct |
16 ms |
760 KB |
Output is correct |
9 |
Correct |
29 ms |
1400 KB |
Output is correct |
10 |
Correct |
3 ms |
376 KB |
Output is correct |
11 |
Correct |
19 ms |
1064 KB |
Output is correct |
12 |
Correct |
33 ms |
1344 KB |
Output is correct |
13 |
Correct |
43 ms |
1372 KB |
Output is correct |
14 |
Correct |
31 ms |
1272 KB |
Output is correct |
15 |
Correct |
86 ms |
3112 KB |
Output is correct |
16 |
Correct |
87 ms |
3124 KB |
Output is correct |
17 |
Correct |
82 ms |
3104 KB |
Output is correct |
18 |
Correct |
83 ms |
3056 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 |
248 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
3 ms |
420 KB |
Output is correct |
6 |
Correct |
5 ms |
424 KB |
Output is correct |
7 |
Correct |
8 ms |
504 KB |
Output is correct |
8 |
Correct |
16 ms |
760 KB |
Output is correct |
9 |
Correct |
29 ms |
1400 KB |
Output is correct |
10 |
Correct |
3 ms |
376 KB |
Output is correct |
11 |
Correct |
19 ms |
1064 KB |
Output is correct |
12 |
Correct |
33 ms |
1344 KB |
Output is correct |
13 |
Correct |
43 ms |
1372 KB |
Output is correct |
14 |
Correct |
31 ms |
1272 KB |
Output is correct |
15 |
Correct |
86 ms |
3112 KB |
Output is correct |
16 |
Correct |
87 ms |
3124 KB |
Output is correct |
17 |
Correct |
82 ms |
3104 KB |
Output is correct |
18 |
Correct |
83 ms |
3056 KB |
Output is correct |
19 |
Correct |
90 ms |
3152 KB |
Output is correct |
20 |
Correct |
89 ms |
3184 KB |
Output is correct |
21 |
Correct |
90 ms |
3176 KB |
Output is correct |
22 |
Correct |
86 ms |
3036 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 |
248 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
3 ms |
420 KB |
Output is correct |
6 |
Correct |
5 ms |
424 KB |
Output is correct |
7 |
Correct |
8 ms |
504 KB |
Output is correct |
8 |
Correct |
16 ms |
760 KB |
Output is correct |
9 |
Correct |
29 ms |
1400 KB |
Output is correct |
10 |
Correct |
3 ms |
376 KB |
Output is correct |
11 |
Correct |
19 ms |
1064 KB |
Output is correct |
12 |
Correct |
33 ms |
1344 KB |
Output is correct |
13 |
Correct |
43 ms |
1372 KB |
Output is correct |
14 |
Correct |
31 ms |
1272 KB |
Output is correct |
15 |
Correct |
86 ms |
3112 KB |
Output is correct |
16 |
Correct |
87 ms |
3124 KB |
Output is correct |
17 |
Correct |
82 ms |
3104 KB |
Output is correct |
18 |
Correct |
83 ms |
3056 KB |
Output is correct |
19 |
Correct |
90 ms |
3152 KB |
Output is correct |
20 |
Correct |
89 ms |
3184 KB |
Output is correct |
21 |
Correct |
90 ms |
3176 KB |
Output is correct |
22 |
Correct |
86 ms |
3036 KB |
Output is correct |
23 |
Correct |
91 ms |
3460 KB |
Output is correct |
24 |
Correct |
89 ms |
3184 KB |
Output is correct |
25 |
Correct |
96 ms |
3292 KB |
Output is correct |
26 |
Correct |
87 ms |
3056 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 |
248 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
3 ms |
420 KB |
Output is correct |
6 |
Correct |
5 ms |
424 KB |
Output is correct |
7 |
Correct |
8 ms |
504 KB |
Output is correct |
8 |
Correct |
16 ms |
760 KB |
Output is correct |
9 |
Correct |
29 ms |
1400 KB |
Output is correct |
10 |
Correct |
3 ms |
376 KB |
Output is correct |
11 |
Correct |
19 ms |
1064 KB |
Output is correct |
12 |
Correct |
33 ms |
1344 KB |
Output is correct |
13 |
Correct |
43 ms |
1372 KB |
Output is correct |
14 |
Correct |
31 ms |
1272 KB |
Output is correct |
15 |
Correct |
86 ms |
3112 KB |
Output is correct |
16 |
Correct |
87 ms |
3124 KB |
Output is correct |
17 |
Correct |
82 ms |
3104 KB |
Output is correct |
18 |
Correct |
83 ms |
3056 KB |
Output is correct |
19 |
Correct |
90 ms |
3152 KB |
Output is correct |
20 |
Correct |
89 ms |
3184 KB |
Output is correct |
21 |
Correct |
90 ms |
3176 KB |
Output is correct |
22 |
Correct |
86 ms |
3036 KB |
Output is correct |
23 |
Correct |
91 ms |
3460 KB |
Output is correct |
24 |
Correct |
89 ms |
3184 KB |
Output is correct |
25 |
Correct |
96 ms |
3292 KB |
Output is correct |
26 |
Correct |
87 ms |
3056 KB |
Output is correct |
27 |
Correct |
96 ms |
3312 KB |
Output is correct |
28 |
Correct |
91 ms |
3232 KB |
Output is correct |
29 |
Correct |
98 ms |
3312 KB |
Output is correct |
30 |
Correct |
91 ms |
3056 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 |
248 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
3 ms |
420 KB |
Output is correct |
6 |
Correct |
5 ms |
424 KB |
Output is correct |
7 |
Correct |
8 ms |
504 KB |
Output is correct |
8 |
Correct |
16 ms |
760 KB |
Output is correct |
9 |
Correct |
29 ms |
1400 KB |
Output is correct |
10 |
Correct |
3 ms |
376 KB |
Output is correct |
11 |
Correct |
19 ms |
1064 KB |
Output is correct |
12 |
Correct |
33 ms |
1344 KB |
Output is correct |
13 |
Correct |
43 ms |
1372 KB |
Output is correct |
14 |
Correct |
31 ms |
1272 KB |
Output is correct |
15 |
Correct |
86 ms |
3112 KB |
Output is correct |
16 |
Correct |
87 ms |
3124 KB |
Output is correct |
17 |
Correct |
82 ms |
3104 KB |
Output is correct |
18 |
Correct |
83 ms |
3056 KB |
Output is correct |
19 |
Correct |
90 ms |
3152 KB |
Output is correct |
20 |
Correct |
89 ms |
3184 KB |
Output is correct |
21 |
Correct |
90 ms |
3176 KB |
Output is correct |
22 |
Correct |
86 ms |
3036 KB |
Output is correct |
23 |
Correct |
91 ms |
3460 KB |
Output is correct |
24 |
Correct |
89 ms |
3184 KB |
Output is correct |
25 |
Correct |
96 ms |
3292 KB |
Output is correct |
26 |
Correct |
87 ms |
3056 KB |
Output is correct |
27 |
Correct |
96 ms |
3312 KB |
Output is correct |
28 |
Correct |
91 ms |
3232 KB |
Output is correct |
29 |
Correct |
98 ms |
3312 KB |
Output is correct |
30 |
Correct |
91 ms |
3056 KB |
Output is correct |
31 |
Correct |
97 ms |
3364 KB |
Output is correct |
32 |
Correct |
95 ms |
3360 KB |
Output is correct |
33 |
Correct |
91 ms |
3312 KB |
Output is correct |
34 |
Correct |
93 ms |
3184 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 |
248 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
3 ms |
420 KB |
Output is correct |
6 |
Correct |
5 ms |
424 KB |
Output is correct |
7 |
Correct |
8 ms |
504 KB |
Output is correct |
8 |
Correct |
16 ms |
760 KB |
Output is correct |
9 |
Correct |
29 ms |
1400 KB |
Output is correct |
10 |
Correct |
3 ms |
376 KB |
Output is correct |
11 |
Correct |
19 ms |
1064 KB |
Output is correct |
12 |
Correct |
33 ms |
1344 KB |
Output is correct |
13 |
Correct |
43 ms |
1372 KB |
Output is correct |
14 |
Correct |
31 ms |
1272 KB |
Output is correct |
15 |
Correct |
86 ms |
3112 KB |
Output is correct |
16 |
Correct |
87 ms |
3124 KB |
Output is correct |
17 |
Correct |
82 ms |
3104 KB |
Output is correct |
18 |
Correct |
83 ms |
3056 KB |
Output is correct |
19 |
Correct |
90 ms |
3152 KB |
Output is correct |
20 |
Correct |
89 ms |
3184 KB |
Output is correct |
21 |
Correct |
90 ms |
3176 KB |
Output is correct |
22 |
Correct |
86 ms |
3036 KB |
Output is correct |
23 |
Correct |
91 ms |
3460 KB |
Output is correct |
24 |
Correct |
89 ms |
3184 KB |
Output is correct |
25 |
Correct |
96 ms |
3292 KB |
Output is correct |
26 |
Correct |
87 ms |
3056 KB |
Output is correct |
27 |
Correct |
96 ms |
3312 KB |
Output is correct |
28 |
Correct |
91 ms |
3232 KB |
Output is correct |
29 |
Correct |
98 ms |
3312 KB |
Output is correct |
30 |
Correct |
91 ms |
3056 KB |
Output is correct |
31 |
Correct |
97 ms |
3364 KB |
Output is correct |
32 |
Correct |
95 ms |
3360 KB |
Output is correct |
33 |
Correct |
91 ms |
3312 KB |
Output is correct |
34 |
Correct |
93 ms |
3184 KB |
Output is correct |
35 |
Incorrect |
96 ms |
3440 KB |
Wrong Answer [2] |
36 |
Halted |
0 ms |
0 KB |
- |