#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];
vector<ll> v,u;
void dnc(vector<ll> v,vector<ll> u)
{
//printf("(%lld %lld)\n",v.size(),u.size());
ll i,m=v.size();
ll mid=m/2,x,s=0;
if(m==1)
{
perm[v[0]]=u[0];
return;
}
for(i=0;i<mid;i++)
{
// printf("! %lld\n",v[i]);
x=Query(v[i]);
s++;
}
vector<ll> v1,v2,u1,u2;
for(i=0;i<mid;i++)
{
v1.push_back(v[i]);
}
for(i=mid;i<m;i++)
{
v2.push_back(v[i]);
}
for(i=0;i<m;i++)
{
// printf("! %lld\n",u[i]);
y=Query(u[i]);
s++;
y=s-y;
// printf("(%lld)\n",y);
if(y>0)
u1.push_back(u[i]);
else
u2.push_back(u[i]);
// printf("! %lld\n",u[i]);
Query(u[i]);
s--;
}
for(i=0;i<mid;i++)
{
// printf("! %lld\n",v[i]);
Query(v[i]);
s--;
}
dnc(v1,u1);
dnc(v2,u2);
}
void f()
{
ll i,x=0,y;
for(i=1;i<=n*2;i++)
{
y=Query(i);
if(y>x)
{
v.push_back(i);
x++;
continue;
}
else
{
Query(i);
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);
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>)':
minerals.cpp:11:16: warning: variable 'x' set but not used [-Wunused-but-set-variable]
11 | ll mid=m/2,x,s=0;
| ^
minerals.cpp: In function 'void Solve(ll)':
minerals.cpp:79:13: warning: comparison of integer expressions of different signedness: 'll' {aka 'int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
79 | for(i=0;i<v.size();i++)
| ~^~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
1 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
344 KB |
Output is correct |
2 |
Correct |
2 ms |
600 KB |
Output is correct |
3 |
Correct |
3 ms |
600 KB |
Output is correct |
4 |
Correct |
6 ms |
856 KB |
Output is correct |
5 |
Correct |
11 ms |
1368 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
1 ms |
344 KB |
Output is correct |
5 |
Correct |
2 ms |
344 KB |
Output is correct |
6 |
Correct |
2 ms |
600 KB |
Output is correct |
7 |
Correct |
3 ms |
600 KB |
Output is correct |
8 |
Correct |
6 ms |
856 KB |
Output is correct |
9 |
Correct |
11 ms |
1368 KB |
Output is correct |
10 |
Correct |
1 ms |
344 KB |
Output is correct |
11 |
Correct |
9 ms |
1276 KB |
Output is correct |
12 |
Correct |
18 ms |
1576 KB |
Output is correct |
13 |
Correct |
11 ms |
1516 KB |
Output is correct |
14 |
Correct |
11 ms |
1532 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
1 ms |
344 KB |
Output is correct |
5 |
Correct |
2 ms |
344 KB |
Output is correct |
6 |
Correct |
2 ms |
600 KB |
Output is correct |
7 |
Correct |
3 ms |
600 KB |
Output is correct |
8 |
Correct |
6 ms |
856 KB |
Output is correct |
9 |
Correct |
11 ms |
1368 KB |
Output is correct |
10 |
Correct |
1 ms |
344 KB |
Output is correct |
11 |
Correct |
9 ms |
1276 KB |
Output is correct |
12 |
Correct |
18 ms |
1576 KB |
Output is correct |
13 |
Correct |
11 ms |
1516 KB |
Output is correct |
14 |
Correct |
11 ms |
1532 KB |
Output is correct |
15 |
Incorrect |
20 ms |
3048 KB |
Wrong Answer [2] |
16 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
1 ms |
344 KB |
Output is correct |
5 |
Correct |
2 ms |
344 KB |
Output is correct |
6 |
Correct |
2 ms |
600 KB |
Output is correct |
7 |
Correct |
3 ms |
600 KB |
Output is correct |
8 |
Correct |
6 ms |
856 KB |
Output is correct |
9 |
Correct |
11 ms |
1368 KB |
Output is correct |
10 |
Correct |
1 ms |
344 KB |
Output is correct |
11 |
Correct |
9 ms |
1276 KB |
Output is correct |
12 |
Correct |
18 ms |
1576 KB |
Output is correct |
13 |
Correct |
11 ms |
1516 KB |
Output is correct |
14 |
Correct |
11 ms |
1532 KB |
Output is correct |
15 |
Incorrect |
20 ms |
3048 KB |
Wrong Answer [2] |
16 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
1 ms |
344 KB |
Output is correct |
5 |
Correct |
2 ms |
344 KB |
Output is correct |
6 |
Correct |
2 ms |
600 KB |
Output is correct |
7 |
Correct |
3 ms |
600 KB |
Output is correct |
8 |
Correct |
6 ms |
856 KB |
Output is correct |
9 |
Correct |
11 ms |
1368 KB |
Output is correct |
10 |
Correct |
1 ms |
344 KB |
Output is correct |
11 |
Correct |
9 ms |
1276 KB |
Output is correct |
12 |
Correct |
18 ms |
1576 KB |
Output is correct |
13 |
Correct |
11 ms |
1516 KB |
Output is correct |
14 |
Correct |
11 ms |
1532 KB |
Output is correct |
15 |
Incorrect |
20 ms |
3048 KB |
Wrong Answer [2] |
16 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
1 ms |
344 KB |
Output is correct |
5 |
Correct |
2 ms |
344 KB |
Output is correct |
6 |
Correct |
2 ms |
600 KB |
Output is correct |
7 |
Correct |
3 ms |
600 KB |
Output is correct |
8 |
Correct |
6 ms |
856 KB |
Output is correct |
9 |
Correct |
11 ms |
1368 KB |
Output is correct |
10 |
Correct |
1 ms |
344 KB |
Output is correct |
11 |
Correct |
9 ms |
1276 KB |
Output is correct |
12 |
Correct |
18 ms |
1576 KB |
Output is correct |
13 |
Correct |
11 ms |
1516 KB |
Output is correct |
14 |
Correct |
11 ms |
1532 KB |
Output is correct |
15 |
Incorrect |
20 ms |
3048 KB |
Wrong Answer [2] |
16 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
1 ms |
344 KB |
Output is correct |
5 |
Correct |
2 ms |
344 KB |
Output is correct |
6 |
Correct |
2 ms |
600 KB |
Output is correct |
7 |
Correct |
3 ms |
600 KB |
Output is correct |
8 |
Correct |
6 ms |
856 KB |
Output is correct |
9 |
Correct |
11 ms |
1368 KB |
Output is correct |
10 |
Correct |
1 ms |
344 KB |
Output is correct |
11 |
Correct |
9 ms |
1276 KB |
Output is correct |
12 |
Correct |
18 ms |
1576 KB |
Output is correct |
13 |
Correct |
11 ms |
1516 KB |
Output is correct |
14 |
Correct |
11 ms |
1532 KB |
Output is correct |
15 |
Incorrect |
20 ms |
3048 KB |
Wrong Answer [2] |
16 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
1 ms |
344 KB |
Output is correct |
5 |
Correct |
2 ms |
344 KB |
Output is correct |
6 |
Correct |
2 ms |
600 KB |
Output is correct |
7 |
Correct |
3 ms |
600 KB |
Output is correct |
8 |
Correct |
6 ms |
856 KB |
Output is correct |
9 |
Correct |
11 ms |
1368 KB |
Output is correct |
10 |
Correct |
1 ms |
344 KB |
Output is correct |
11 |
Correct |
9 ms |
1276 KB |
Output is correct |
12 |
Correct |
18 ms |
1576 KB |
Output is correct |
13 |
Correct |
11 ms |
1516 KB |
Output is correct |
14 |
Correct |
11 ms |
1532 KB |
Output is correct |
15 |
Incorrect |
20 ms |
3048 KB |
Wrong Answer [2] |
16 |
Halted |
0 ms |
0 KB |
- |