이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "minerals.h"
#include<bits/stdc++.h>
using namespace std;
const int nmax=1e5+42;
int used=0;
int colour[nmax]={0,1,2,3,3,1,2,4,4};
int cnt[nmax];
bool in[nmax];
int CURRENT;
/*
int Query(int pos)
{
used++;
CURRENT=CURRENT-(cnt[colour[pos]]>0);
if(in[pos])
{
in[pos]=0;
cnt[colour[pos]]--;
}
else
{
in[pos]=1;
cnt[colour[pos]]++;
}
CURRENT=CURRENT+(cnt[colour[pos]]>0);
return CURRENT;
}
void Answer(int a,int b)
{
return;
cout<<a<<" "<<b<<endl;
}
*/
vector< pair<int,int> > outp;
int current=0;
int which_is_active(int le,int ri)
{
if(le)return 0;
return 1;
}
void solve(vector<int> lhs,vector<int> rhs,bool active_lhs,bool active_rhs)
{
/*
cout<<active_lhs<<" LHS: ";for(auto k:lhs)cout<<k<<" ";cout<<endl;
cout<<active_rhs<<" 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]);
bool type_lhs[2]={!active_lhs,active_lhs};
bool type_rhs[2]={!active_rhs,!active_rhs};
for(auto k:rhs)
{
int mem=Query(k);
if(active_rhs==0)
{
if(current==mem)rhs_new[which_is_active(type_lhs[0],type_lhs[1])].push_back(k);
else rhs_new[!which_is_active(type_lhs[0],type_lhs[1])].push_back(k);
}
else//active_rhs=1
{
if(current==mem)rhs_new[which_is_active(type_lhs[0],type_lhs[1])].push_back(k);
else rhs_new[!which_is_active(type_lhs[0],type_lhs[1])].push_back(k);
}
current=mem;
}
solve(lhs_new[0],rhs_new[0],type_lhs[0],type_rhs[0]);
solve(lhs_new[1],rhs_new[1],type_lhs[1],type_rhs[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;
}
solve(lhs,rhs,1,1);
for(int i=0;i<n;i++)
Answer(outp[i].first,outp[i].second);
}
/*
int n;
void create()
{
for(int i=1;i<=n;i++)
colour[i]=i;
for(int i=n+1;i<=2*n;i++)
colour[i]=i-n;
}
int main()
{
n=4.3e4;
create();
Solve(n);
cout<<"used= "<<used<<endl;
return 0;
}
*/
컴파일 시 표준 에러 (stderr) 메시지
minerals.cpp: In function 'void solve(std::vector<int>, std::vector<int>, bool, bool)':
minerals.cpp:82:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=mid;i<lhs.size();i++)
~^~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |