답안 #15480

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
15480 2015-07-12T08:18:06 Z myungwoo 통로 위의 개미 (kriii3_X) C++14
0 / 85
34 ms 7976 KB
#include <bits/stdc++.h>
using namespace std;

#define MAXM 200005
#define pb push_back
typedef long long lld;

int L, M, N;
lld pos[MAXM];

struct Z{
	lld t;
	int p, x, d;
} Q[MAXM];

int main()
{
	scanf("%d%d", &L, &M);
	for (int i=1;i<=M;i++){
		scanf("%d%d%d", &Q[i].t, &Q[i].p, &Q[i].x);
		if (Q[i].p == 1) scanf("%d", &Q[i].d);
	}
	sort(Q+1, Q+M+1, [](const Z &a, const Z &b){
		return a.t < b.t;
	});
	vector <int> ord(1, 0);
	for (int qq=1;qq<=M;qq++){
		Z &q = Q[qq];
		vector <lld> arr(N+1, 0);
		for (int i=1;i<=N;i++){
			arr[i] = (pos[i] + q.t) % (L+L);
			if (arr[i] > L) arr[i] = L - (arr[i] - L);
		}
		sort(arr.begin()+1, arr.end());
		if (q.p == 1){
			if (q.d == 1){
				pos[++N] = q.x - q.t;
			}else{
				pos[++N] = L+L - q.x - q.t;
			}
			int t = 0;
			for (int i=1;i<N;i++) if (arr[i] < q.x) t = i;
			ord.pb(0);
			for (int i=N-1;i>t;i--) ord[i+1] = ord[i];
			ord[t+1] = N;
		}else{
			for (int i=1;i<=N;i++) if (ord[i] == q.x) printf("%lld\n", arr[i]);
		}
	}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 26 ms 7976 KB Output is correct
2 Correct 28 ms 7976 KB Output is correct
3 Correct 27 ms 7976 KB Output is correct
4 Correct 30 ms 7976 KB Output is correct
5 Correct 26 ms 7976 KB Output is correct
6 Correct 27 ms 7976 KB Output is correct
7 Correct 26 ms 7976 KB Output is correct
8 Correct 26 ms 7976 KB Output is correct
9 Correct 26 ms 7976 KB Output is correct
10 Correct 27 ms 7976 KB Output is correct
11 Correct 14 ms 7976 KB Output is correct
12 Correct 21 ms 7976 KB Output is correct
13 Correct 10 ms 7976 KB Output is correct
14 Correct 12 ms 7976 KB Output is correct
15 Correct 15 ms 7976 KB Output is correct
16 Correct 34 ms 7976 KB Output is correct
17 Correct 33 ms 7976 KB Output is correct
18 Correct 26 ms 7976 KB Output is correct
19 Correct 14 ms 7976 KB Output is correct
20 Correct 25 ms 7976 KB Output is correct
21 Incorrect 9 ms 7976 KB Output isn't correct
22 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Halted 0 ms 0 KB -