#include "minerals.h"
#include<bits/stdc++.h>
using namespace std;
/*
int colour[10]={0,1,2,3,3,1,2,4,4};
int cnt[10];
bool in[10];
int Query(int pos)
{
if(in[pos])
{
in[pos]=0;
cnt[colour[pos]]--;
}
else
{
in[pos]=1;
cnt[colour[pos]]++;
}
int ret=0;
for(int i=1;i<=4;i++)ret=ret+(cnt[i]>0);
cout<<"Query "<<pos<<" -> "<<ret<<endl;
return ret;
}
void Answer(int a,int b)
{
cout<<a<<" "<<b<<endl;
}
*/
vector< pair<int,int> > outp;
int current=0;
void solve(vector<int> lhs,vector<int> rhs)
{
/*
cout<<"LHS: ";for(auto k:lhs)cout<<k<<" ";cout<<endl;
cout<<"RHS: ";for(auto k:rhs)cout<<k<<" ";cout<<endl;
cout<<"---"<<endl;
*/
if(lhs.size()==1)
{
outp.push_back({lhs[0],rhs[0]});
return;
}
int mid=lhs.size()/2;
vector<int> lhs_new[2],rhs_new[2];
lhs_new[0]={};lhs_new[1]={};
rhs_new[0]={};rhs_new[1]={};
for(int i=0;i<mid;i++)
{
int mem=Query(lhs[i]);
current=mem;
lhs_new[0].push_back(lhs[i]);
}
for(int i=mid;i<lhs.size();i++)
lhs_new[1].push_back(lhs[i]);
for(auto k:rhs)
{
int mem=Query(k);
if(current==mem)rhs_new[0].push_back(k);
else rhs_new[1].push_back(k);
current=mem;
}
for(auto k:rhs)
Query(k);
for(int i=0;i<mid;i++)
Query(lhs[i]);
current=0;
solve(lhs_new[0],rhs_new[0]);
solve(lhs_new[1],rhs_new[1]);
}
void Solve(int n)
{
vector<int> lhs={},rhs={};
for(int i=1;i<=2*n;i++)
{
int mem=Query(i);
if(current<mem)lhs.push_back(i);
else rhs.push_back(i);
current=mem;
}
for(int i=1;i<=2*n;i++)
Query(i);
current=0;
solve(lhs,rhs);
for(int i=0;i<n;i++)
Answer(outp[i].first,outp[i].second);
}
/*
int main()
{
Solve(4);
return 0;
}
*/
Compilation message
minerals.cpp: In function 'void solve(std::vector<int>, std::vector<int>)':
minerals.cpp:67:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=mid;i<lhs.size();i++)
~^~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
384 KB |
Output is correct |
2 |
Correct |
7 ms |
512 KB |
Output is correct |
3 |
Correct |
11 ms |
640 KB |
Output is correct |
4 |
Correct |
19 ms |
1000 KB |
Output is correct |
5 |
Correct |
30 ms |
1504 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
6 ms |
384 KB |
Output is correct |
6 |
Correct |
7 ms |
512 KB |
Output is correct |
7 |
Correct |
11 ms |
640 KB |
Output is correct |
8 |
Correct |
19 ms |
1000 KB |
Output is correct |
9 |
Correct |
30 ms |
1504 KB |
Output is correct |
10 |
Correct |
6 ms |
384 KB |
Output is correct |
11 |
Correct |
20 ms |
1268 KB |
Output is correct |
12 |
Correct |
36 ms |
1536 KB |
Output is correct |
13 |
Correct |
27 ms |
1536 KB |
Output is correct |
14 |
Correct |
24 ms |
1516 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
6 ms |
384 KB |
Output is correct |
6 |
Correct |
7 ms |
512 KB |
Output is correct |
7 |
Correct |
11 ms |
640 KB |
Output is correct |
8 |
Correct |
19 ms |
1000 KB |
Output is correct |
9 |
Correct |
30 ms |
1504 KB |
Output is correct |
10 |
Correct |
6 ms |
384 KB |
Output is correct |
11 |
Correct |
20 ms |
1268 KB |
Output is correct |
12 |
Correct |
36 ms |
1536 KB |
Output is correct |
13 |
Correct |
27 ms |
1536 KB |
Output is correct |
14 |
Correct |
24 ms |
1516 KB |
Output is correct |
15 |
Incorrect |
49 ms |
3320 KB |
Wrong Answer [2] |
16 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
6 ms |
384 KB |
Output is correct |
6 |
Correct |
7 ms |
512 KB |
Output is correct |
7 |
Correct |
11 ms |
640 KB |
Output is correct |
8 |
Correct |
19 ms |
1000 KB |
Output is correct |
9 |
Correct |
30 ms |
1504 KB |
Output is correct |
10 |
Correct |
6 ms |
384 KB |
Output is correct |
11 |
Correct |
20 ms |
1268 KB |
Output is correct |
12 |
Correct |
36 ms |
1536 KB |
Output is correct |
13 |
Correct |
27 ms |
1536 KB |
Output is correct |
14 |
Correct |
24 ms |
1516 KB |
Output is correct |
15 |
Incorrect |
49 ms |
3320 KB |
Wrong Answer [2] |
16 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
6 ms |
384 KB |
Output is correct |
6 |
Correct |
7 ms |
512 KB |
Output is correct |
7 |
Correct |
11 ms |
640 KB |
Output is correct |
8 |
Correct |
19 ms |
1000 KB |
Output is correct |
9 |
Correct |
30 ms |
1504 KB |
Output is correct |
10 |
Correct |
6 ms |
384 KB |
Output is correct |
11 |
Correct |
20 ms |
1268 KB |
Output is correct |
12 |
Correct |
36 ms |
1536 KB |
Output is correct |
13 |
Correct |
27 ms |
1536 KB |
Output is correct |
14 |
Correct |
24 ms |
1516 KB |
Output is correct |
15 |
Incorrect |
49 ms |
3320 KB |
Wrong Answer [2] |
16 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
6 ms |
384 KB |
Output is correct |
6 |
Correct |
7 ms |
512 KB |
Output is correct |
7 |
Correct |
11 ms |
640 KB |
Output is correct |
8 |
Correct |
19 ms |
1000 KB |
Output is correct |
9 |
Correct |
30 ms |
1504 KB |
Output is correct |
10 |
Correct |
6 ms |
384 KB |
Output is correct |
11 |
Correct |
20 ms |
1268 KB |
Output is correct |
12 |
Correct |
36 ms |
1536 KB |
Output is correct |
13 |
Correct |
27 ms |
1536 KB |
Output is correct |
14 |
Correct |
24 ms |
1516 KB |
Output is correct |
15 |
Incorrect |
49 ms |
3320 KB |
Wrong Answer [2] |
16 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
6 ms |
384 KB |
Output is correct |
6 |
Correct |
7 ms |
512 KB |
Output is correct |
7 |
Correct |
11 ms |
640 KB |
Output is correct |
8 |
Correct |
19 ms |
1000 KB |
Output is correct |
9 |
Correct |
30 ms |
1504 KB |
Output is correct |
10 |
Correct |
6 ms |
384 KB |
Output is correct |
11 |
Correct |
20 ms |
1268 KB |
Output is correct |
12 |
Correct |
36 ms |
1536 KB |
Output is correct |
13 |
Correct |
27 ms |
1536 KB |
Output is correct |
14 |
Correct |
24 ms |
1516 KB |
Output is correct |
15 |
Incorrect |
49 ms |
3320 KB |
Wrong Answer [2] |
16 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
6 ms |
384 KB |
Output is correct |
6 |
Correct |
7 ms |
512 KB |
Output is correct |
7 |
Correct |
11 ms |
640 KB |
Output is correct |
8 |
Correct |
19 ms |
1000 KB |
Output is correct |
9 |
Correct |
30 ms |
1504 KB |
Output is correct |
10 |
Correct |
6 ms |
384 KB |
Output is correct |
11 |
Correct |
20 ms |
1268 KB |
Output is correct |
12 |
Correct |
36 ms |
1536 KB |
Output is correct |
13 |
Correct |
27 ms |
1536 KB |
Output is correct |
14 |
Correct |
24 ms |
1516 KB |
Output is correct |
15 |
Incorrect |
49 ms |
3320 KB |
Wrong Answer [2] |
16 |
Halted |
0 ms |
0 KB |
- |