문제 설명
의 n 개미 길이 L은 스틱 각 개미 크롤링 또는 1cm / sec로 좌우로 상승 속도 CM.
두 개미 충돌 할 때 동시에 두 돌아서 (무시할 수있는 시간을 돌아서).
각 개미 초기 위치와 배향은 계산 후 각 개미 T 초 위치를 지정.
입력 포맷
첫번째 입력 데이터 세트 동작의 수. 3 양의 정수 L, T, N (0≤n≤10 000 ) , 각 데이터의 첫 번째 행의 n은 라인 개미 초기 위치에 대한 다음의 설명의 각각
의 거리 x는 스틱의 좌단에서 개미의 정수이고 (단위 : cm)는 문자 (L은 R이 우측으로 나타내는 좌측을 나타낸다)의 초기 방향을 나타낸다.
출력 형식
각 개미의 입력 위치와 방향에 따라 각각의 시험에있어서, n 출력 선 순차적으로 출력 (선삭 충돌이 표시된다).
T 초 첫 번째 떨어졌다 개미 스틱 전에 (정확히 스틱 상승 에지) 출력이 떨어졌다.
샘플 입력. (1)
(2)
10 4 1
. 1 및 R LT
. 5 및 R LT
. 3 L
10 및 R LT
10 2 3
. 4 및 R LT
. 5 L
. 8 R & LT
출력 샘플 1이다.
사례 1 :.
2 선삭
. 6 R & LT
선삭 2
떨어진 OFF를
사례 2 :
3 L
6 R
10 R
PS :
나는 두 개미 통과로 사용할 수있는 두 개미와 충돌 할 때
내가 주위를 다시 켜진 상태,하지만 내 위치가 상대적으로 변경되지 않은 상태
가을에 시작 I를 언제나 가장이 결장했다
package 第七次模拟;
import java.util.Arrays;
import java.util.Scanner;
public class Demo2蚂蚁 {
public static class Node implements Comparable<Node> {
int id;// 输入顺序
int location;// -1,0,1
int p;// 位置
@Override
public int compareTo(Node o) {
// TODO 自动生成的方法存根
if (this.p > o.p) {
return 1;
} else if (this.p < o.p) {
return -1;
}
return 0;
}
}
public static Node[] start;
public static Node[] end;
public static int[] order;
public static String[] loca = { "L", "Turning", "R" };;
public static void main(String[] args) {
int num=1;
Scanner sc = new Scanner(System.in);
int count = sc.nextInt();
while (count-- > 0) {
int l = sc.nextInt();
int t = sc.nextInt();
int n = sc.nextInt();
start = new Node[n];
end = new Node[n];
order = new int[n];
for (int i = 0; i < n; i++) {
start[i] = new Node();
start[i].p = sc.nextInt();
String c = sc.next();
if (c.equals("L"))
start[i].location = -1;
else
start[i].location = 1;
start[i].id = i;
end[i] = new Node();
end[i].id = 0;
end[i].p = start[i].p + t * start[i].location;
end[i].location = start[i].location;
}
Arrays.sort(start);
Arrays.sort(end);
for (int j = 0; j < n; j++) {
order[start[j].id] = j;
}
for (int j = 0; j < n - 1; j++) {
if (end[j].p == end[j + 1].p) {
end[j].location = 0;
end[j + 1].location = 0;
}
}
System.out.println("Case #"+ num++ +":");
for (int i = 0; i < n; i++) {
int temp = order[i];
if (end[temp].p > l || end[temp].p < 0) {
System.out.println("Fell off\n");
} else {
System.out.println(end[temp].p + " " + loca[end[temp].location + 1]);
}
}
}
}
}