#include "minerals.h"
#include<bits/stdc++.h>
using namespace std;
typedef int ll;
ll n,i,j,k,l,r,x,y,z,w,s,t,perm[1100000],b[1100000];
vector<ll> v,u;
void dnc(vector<ll> v,vector<ll> u,ll z)
{
//printf("(%lld %lld)\n",v.size(),u.size());
ll i,m=v.size();
ll mid=m/2,x,y;
if(m>=20&&z==0)
mid=m/5*2;
if(m>=20&&z==1)
mid=m/5*3;
vector<ll> v1,v2,u1,u2;
if(m==1)
{
perm[v[0]]=u[0];
return;
}
if(z==0)
{for(i=0;i<mid;i++)
{
//printf("! %lld\n",v[i]);
x=Query(v[i]);
s++;
}}
else
{
for(i=mid;i<m;i++)
{
//printf("! %lld\n",v[i]);
x=Query(v[i]);
s--;
}
}
for(i=0;i<mid;i++)
{
v1.push_back(v[i]);
}
for(i=mid;i<m;i++)
{
v2.push_back(v[i]);
}
x=s-x;
for(i=0;i<m;i++)
{
if(i==m-1)
{
if(u1.size()<mid)
{
u1.push_back(u[i]);
}
else
u2.push_back(u[i]);
continue;
}
//printf("! %lld\n",u[i]);
y=Query(u[i]);
if(b[u[i]]==0)
s++;
else
s--;
b[u[i]]^=1;
y=s-y;
//printf("(%lld)\n",y);
if(y!=x)
u1.push_back(u[i]);
else
u2.push_back(u[i]);
// printf("! %lld\n",u[i]);
x=y;
}
dnc(v2,u2,0);
dnc(v1,u1,1);
}
void f()
{
ll i,x=0,y;
for(i=1;i<=n*2;i++)
{
y=Query(i);
s++;
if(y>x)
{
v.push_back(i);
x++;
continue;
}
else
{
Query(i);
s--;
u.push_back(i);
continue;
}
}
}
void Solve(ll N) {
n=N;
f();
/*for(i=0;i<v.size();i++)
{
Query(v[i]);
}*/
dnc(v,u,1);
for(i=1;i<=n*2;i++)
{
if(perm[i]==0)
continue;
Answer(i,perm[i]);
}
}
Compilation message
minerals.cpp: In function 'void dnc(std::vector<int>, std::vector<int>, ll)':
minerals.cpp:52:25: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'll' {aka 'int'} [-Wsign-compare]
52 | if(u1.size()<mid)
| ~~~~~~~~~^~~~
minerals.cpp:47:6: warning: 'x' may be used uninitialized in this function [-Wmaybe-uninitialized]
47 | x=s-x;
| ~^~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Correct |
1 ms |
2392 KB |
Output is correct |
3 |
Correct |
1 ms |
2392 KB |
Output is correct |
4 |
Correct |
1 ms |
2392 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Correct |
2 ms |
2648 KB |
Output is correct |
3 |
Correct |
3 ms |
2648 KB |
Output is correct |
4 |
Correct |
6 ms |
3160 KB |
Output is correct |
5 |
Correct |
13 ms |
3672 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Correct |
1 ms |
2392 KB |
Output is correct |
3 |
Correct |
1 ms |
2392 KB |
Output is correct |
4 |
Correct |
1 ms |
2392 KB |
Output is correct |
5 |
Correct |
1 ms |
2392 KB |
Output is correct |
6 |
Correct |
2 ms |
2648 KB |
Output is correct |
7 |
Correct |
3 ms |
2648 KB |
Output is correct |
8 |
Correct |
6 ms |
3160 KB |
Output is correct |
9 |
Correct |
13 ms |
3672 KB |
Output is correct |
10 |
Correct |
2 ms |
2392 KB |
Output is correct |
11 |
Correct |
8 ms |
3416 KB |
Output is correct |
12 |
Correct |
12 ms |
3940 KB |
Output is correct |
13 |
Correct |
10 ms |
3804 KB |
Output is correct |
14 |
Correct |
9 ms |
3672 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Correct |
1 ms |
2392 KB |
Output is correct |
3 |
Correct |
1 ms |
2392 KB |
Output is correct |
4 |
Correct |
1 ms |
2392 KB |
Output is correct |
5 |
Correct |
1 ms |
2392 KB |
Output is correct |
6 |
Correct |
2 ms |
2648 KB |
Output is correct |
7 |
Correct |
3 ms |
2648 KB |
Output is correct |
8 |
Correct |
6 ms |
3160 KB |
Output is correct |
9 |
Correct |
13 ms |
3672 KB |
Output is correct |
10 |
Correct |
2 ms |
2392 KB |
Output is correct |
11 |
Correct |
8 ms |
3416 KB |
Output is correct |
12 |
Correct |
12 ms |
3940 KB |
Output is correct |
13 |
Correct |
10 ms |
3804 KB |
Output is correct |
14 |
Correct |
9 ms |
3672 KB |
Output is correct |
15 |
Correct |
30 ms |
5604 KB |
Output is correct |
16 |
Correct |
30 ms |
5584 KB |
Output is correct |
17 |
Correct |
24 ms |
6076 KB |
Output is correct |
18 |
Correct |
25 ms |
5340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Correct |
1 ms |
2392 KB |
Output is correct |
3 |
Correct |
1 ms |
2392 KB |
Output is correct |
4 |
Correct |
1 ms |
2392 KB |
Output is correct |
5 |
Correct |
1 ms |
2392 KB |
Output is correct |
6 |
Correct |
2 ms |
2648 KB |
Output is correct |
7 |
Correct |
3 ms |
2648 KB |
Output is correct |
8 |
Correct |
6 ms |
3160 KB |
Output is correct |
9 |
Correct |
13 ms |
3672 KB |
Output is correct |
10 |
Correct |
2 ms |
2392 KB |
Output is correct |
11 |
Correct |
8 ms |
3416 KB |
Output is correct |
12 |
Correct |
12 ms |
3940 KB |
Output is correct |
13 |
Correct |
10 ms |
3804 KB |
Output is correct |
14 |
Correct |
9 ms |
3672 KB |
Output is correct |
15 |
Correct |
30 ms |
5604 KB |
Output is correct |
16 |
Correct |
30 ms |
5584 KB |
Output is correct |
17 |
Correct |
24 ms |
6076 KB |
Output is correct |
18 |
Correct |
25 ms |
5340 KB |
Output is correct |
19 |
Correct |
35 ms |
5608 KB |
Output is correct |
20 |
Correct |
34 ms |
5616 KB |
Output is correct |
21 |
Correct |
26 ms |
6252 KB |
Output is correct |
22 |
Correct |
28 ms |
5464 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Correct |
1 ms |
2392 KB |
Output is correct |
3 |
Correct |
1 ms |
2392 KB |
Output is correct |
4 |
Correct |
1 ms |
2392 KB |
Output is correct |
5 |
Correct |
1 ms |
2392 KB |
Output is correct |
6 |
Correct |
2 ms |
2648 KB |
Output is correct |
7 |
Correct |
3 ms |
2648 KB |
Output is correct |
8 |
Correct |
6 ms |
3160 KB |
Output is correct |
9 |
Correct |
13 ms |
3672 KB |
Output is correct |
10 |
Correct |
2 ms |
2392 KB |
Output is correct |
11 |
Correct |
8 ms |
3416 KB |
Output is correct |
12 |
Correct |
12 ms |
3940 KB |
Output is correct |
13 |
Correct |
10 ms |
3804 KB |
Output is correct |
14 |
Correct |
9 ms |
3672 KB |
Output is correct |
15 |
Correct |
30 ms |
5604 KB |
Output is correct |
16 |
Correct |
30 ms |
5584 KB |
Output is correct |
17 |
Correct |
24 ms |
6076 KB |
Output is correct |
18 |
Correct |
25 ms |
5340 KB |
Output is correct |
19 |
Correct |
35 ms |
5608 KB |
Output is correct |
20 |
Correct |
34 ms |
5616 KB |
Output is correct |
21 |
Correct |
26 ms |
6252 KB |
Output is correct |
22 |
Correct |
28 ms |
5464 KB |
Output is correct |
23 |
Correct |
31 ms |
5708 KB |
Output is correct |
24 |
Correct |
34 ms |
5968 KB |
Output is correct |
25 |
Correct |
25 ms |
5920 KB |
Output is correct |
26 |
Correct |
26 ms |
5628 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Correct |
1 ms |
2392 KB |
Output is correct |
3 |
Correct |
1 ms |
2392 KB |
Output is correct |
4 |
Correct |
1 ms |
2392 KB |
Output is correct |
5 |
Correct |
1 ms |
2392 KB |
Output is correct |
6 |
Correct |
2 ms |
2648 KB |
Output is correct |
7 |
Correct |
3 ms |
2648 KB |
Output is correct |
8 |
Correct |
6 ms |
3160 KB |
Output is correct |
9 |
Correct |
13 ms |
3672 KB |
Output is correct |
10 |
Correct |
2 ms |
2392 KB |
Output is correct |
11 |
Correct |
8 ms |
3416 KB |
Output is correct |
12 |
Correct |
12 ms |
3940 KB |
Output is correct |
13 |
Correct |
10 ms |
3804 KB |
Output is correct |
14 |
Correct |
9 ms |
3672 KB |
Output is correct |
15 |
Correct |
30 ms |
5604 KB |
Output is correct |
16 |
Correct |
30 ms |
5584 KB |
Output is correct |
17 |
Correct |
24 ms |
6076 KB |
Output is correct |
18 |
Correct |
25 ms |
5340 KB |
Output is correct |
19 |
Correct |
35 ms |
5608 KB |
Output is correct |
20 |
Correct |
34 ms |
5616 KB |
Output is correct |
21 |
Correct |
26 ms |
6252 KB |
Output is correct |
22 |
Correct |
28 ms |
5464 KB |
Output is correct |
23 |
Correct |
31 ms |
5708 KB |
Output is correct |
24 |
Correct |
34 ms |
5968 KB |
Output is correct |
25 |
Correct |
25 ms |
5920 KB |
Output is correct |
26 |
Correct |
26 ms |
5628 KB |
Output is correct |
27 |
Correct |
32 ms |
5848 KB |
Output is correct |
28 |
Correct |
33 ms |
5872 KB |
Output is correct |
29 |
Correct |
26 ms |
6392 KB |
Output is correct |
30 |
Correct |
25 ms |
5428 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Correct |
1 ms |
2392 KB |
Output is correct |
3 |
Correct |
1 ms |
2392 KB |
Output is correct |
4 |
Correct |
1 ms |
2392 KB |
Output is correct |
5 |
Correct |
1 ms |
2392 KB |
Output is correct |
6 |
Correct |
2 ms |
2648 KB |
Output is correct |
7 |
Correct |
3 ms |
2648 KB |
Output is correct |
8 |
Correct |
6 ms |
3160 KB |
Output is correct |
9 |
Correct |
13 ms |
3672 KB |
Output is correct |
10 |
Correct |
2 ms |
2392 KB |
Output is correct |
11 |
Correct |
8 ms |
3416 KB |
Output is correct |
12 |
Correct |
12 ms |
3940 KB |
Output is correct |
13 |
Correct |
10 ms |
3804 KB |
Output is correct |
14 |
Correct |
9 ms |
3672 KB |
Output is correct |
15 |
Correct |
30 ms |
5604 KB |
Output is correct |
16 |
Correct |
30 ms |
5584 KB |
Output is correct |
17 |
Correct |
24 ms |
6076 KB |
Output is correct |
18 |
Correct |
25 ms |
5340 KB |
Output is correct |
19 |
Correct |
35 ms |
5608 KB |
Output is correct |
20 |
Correct |
34 ms |
5616 KB |
Output is correct |
21 |
Correct |
26 ms |
6252 KB |
Output is correct |
22 |
Correct |
28 ms |
5464 KB |
Output is correct |
23 |
Correct |
31 ms |
5708 KB |
Output is correct |
24 |
Correct |
34 ms |
5968 KB |
Output is correct |
25 |
Correct |
25 ms |
5920 KB |
Output is correct |
26 |
Correct |
26 ms |
5628 KB |
Output is correct |
27 |
Correct |
32 ms |
5848 KB |
Output is correct |
28 |
Correct |
33 ms |
5872 KB |
Output is correct |
29 |
Correct |
26 ms |
6392 KB |
Output is correct |
30 |
Correct |
25 ms |
5428 KB |
Output is correct |
31 |
Incorrect |
34 ms |
5852 KB |
Wrong Answer [2] |
32 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Correct |
1 ms |
2392 KB |
Output is correct |
3 |
Correct |
1 ms |
2392 KB |
Output is correct |
4 |
Correct |
1 ms |
2392 KB |
Output is correct |
5 |
Correct |
1 ms |
2392 KB |
Output is correct |
6 |
Correct |
2 ms |
2648 KB |
Output is correct |
7 |
Correct |
3 ms |
2648 KB |
Output is correct |
8 |
Correct |
6 ms |
3160 KB |
Output is correct |
9 |
Correct |
13 ms |
3672 KB |
Output is correct |
10 |
Correct |
2 ms |
2392 KB |
Output is correct |
11 |
Correct |
8 ms |
3416 KB |
Output is correct |
12 |
Correct |
12 ms |
3940 KB |
Output is correct |
13 |
Correct |
10 ms |
3804 KB |
Output is correct |
14 |
Correct |
9 ms |
3672 KB |
Output is correct |
15 |
Correct |
30 ms |
5604 KB |
Output is correct |
16 |
Correct |
30 ms |
5584 KB |
Output is correct |
17 |
Correct |
24 ms |
6076 KB |
Output is correct |
18 |
Correct |
25 ms |
5340 KB |
Output is correct |
19 |
Correct |
35 ms |
5608 KB |
Output is correct |
20 |
Correct |
34 ms |
5616 KB |
Output is correct |
21 |
Correct |
26 ms |
6252 KB |
Output is correct |
22 |
Correct |
28 ms |
5464 KB |
Output is correct |
23 |
Correct |
31 ms |
5708 KB |
Output is correct |
24 |
Correct |
34 ms |
5968 KB |
Output is correct |
25 |
Correct |
25 ms |
5920 KB |
Output is correct |
26 |
Correct |
26 ms |
5628 KB |
Output is correct |
27 |
Correct |
32 ms |
5848 KB |
Output is correct |
28 |
Correct |
33 ms |
5872 KB |
Output is correct |
29 |
Correct |
26 ms |
6392 KB |
Output is correct |
30 |
Correct |
25 ms |
5428 KB |
Output is correct |
31 |
Incorrect |
34 ms |
5852 KB |
Wrong Answer [2] |
32 |
Halted |
0 ms |
0 KB |
- |