This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
#include "light.h"
#define int long long
using namespace std;
int n=1;
vector<int> teraz;
void prepare()
{
teraz.push_back(1);
}
void zmien(int p)
{
vector<int> nowe;
nowe.push_back(n);
int jestem=n;
while(jestem>1)
{
jestem-=(n-jestem+2);
if(jestem<=0)
jestem=1;
int gdzie=upper_bound(teraz.begin(),teraz.end(),jestem)-teraz.begin();
gdzie--;
if(jestem-teraz[gdzie]>p)
jestem=teraz[gdzie+1];
nowe.push_back(jestem);
}
reverse(nowe.begin(),nowe.end());
swap(nowe,teraz);
}
pair<int,vector<int> > join(int p)
{
n+=p;
zmien(p);
return {p,teraz};
}
pair<int,vector<int> > leave(int p)
{
n-=p;
zmien(p);
return {p,teraz};
}
/*int32_t main()
{
prepare();
while(true)
{
int typ,ile;
cin>>typ>>ile;
pair<int,vector<int> > mam;
if(typ==0)
mam=join(ile);
else mam=leave(ile);
cout<<mam.first<<" ";
for(int i=0;i<mam.second.size();i++)
cout<<mam.second[i]<<" ";
cout<<"\n";
}
}*/
# | 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... |