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<cstdio>
#include<algorithm>
using namespace std;
pair<int,int> arix[1010];
int order[1010];
int tp=0;
int L,Q;
void update(int t)
{
t%=2*L;
for(int i=0;i<tp;i++)
{
arix[i].first+=arix[i].second*t;
while(arix[i].first<0 || arix[i].first>L)
{
if(arix[i].first<0)
{
arix[i].first*=-1;
arix[i].second*=-1;
}
else
{
arix[i].first=2*L-arix[i].first;
arix[i].second*=-1;
}
}
}
sort(arix,arix+tp);
return;
}
int main()
{
scanf("%d%d",&L,&Q);
int pt=0;
for(int i=0;i<Q;i++)
{
int t;
scanf("%d",&t);
update(t-pt);
pt=t;
int tt;
scanf("%d",&tt);
if(tt==1)
{
int x,d;
scanf("%d%d",&x,&d);
arix[tp]=make_pair(x,d);
for(int i=0;i<tp;i++)
if(arix[i].first<x)
order[tp]++;
for(int i=0;i<tp;i++)
if(order[i]>=order[tp]) order[i]++;
tp++;
}
else
{
int c;
scanf("%d",&c);
printf("%d\n",arix[order[c-1]].first);
}
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |