Submission #15472

# Submission time Handle Problem Language Result Execution time Memory
15472 2015-07-12T08:12:56 Z progressive 통로 위의 개미 (kriii3_X) C++14
0 / 85
28 ms 1096 KB
#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
1 Correct 19 ms 1096 KB Output is correct
2 Correct 19 ms 1096 KB Output is correct
3 Correct 20 ms 1096 KB Output is correct
4 Correct 26 ms 1096 KB Output is correct
5 Correct 16 ms 1096 KB Output is correct
6 Correct 22 ms 1096 KB Output is correct
7 Correct 19 ms 1096 KB Output is correct
8 Correct 15 ms 1096 KB Output is correct
9 Correct 15 ms 1096 KB Output is correct
10 Correct 20 ms 1096 KB Output is correct
11 Correct 12 ms 1096 KB Output is correct
12 Correct 16 ms 1096 KB Output is correct
13 Correct 6 ms 1096 KB Output is correct
14 Correct 7 ms 1096 KB Output is correct
15 Correct 11 ms 1096 KB Output is correct
16 Correct 28 ms 1096 KB Output is correct
17 Correct 27 ms 1096 KB Output is correct
18 Correct 19 ms 1096 KB Output is correct
19 Correct 12 ms 1096 KB Output is correct
20 Correct 21 ms 1096 KB Output is correct
21 Incorrect 5 ms 1096 KB Output isn't correct
22 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Halted 0 ms 0 KB -