結果
| 問題 |
No.2564 衝突予測
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-12-02 15:18:40 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 566 ms / 2,000 ms |
| コード長 | 2,188 bytes |
| コンパイル時間 | 5,491 ms |
| コンパイル使用メモリ | 77,220 KB |
| 実行使用メモリ | 46,500 KB |
| 最終ジャッジ日時 | 2024-09-26 18:27:09 |
| 合計ジャッジ時間 | 9,809 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 9 |
ソースコード
import java.util.*;
import java.io.*;
class Main{
private static final BufferedReader br =
new BufferedReader(new InputStreamReader(System.in));
private static final PrintWriter out =
new PrintWriter(System.out);
public static void main(String[] args)throws IOException{
int T = Integer.parseInt(br.readLine());
while(T-->0){
String[] str;
str = br.readLine().split(" ");
int x1 = Integer.parseInt(str[0]);
int y1 = Integer.parseInt(str[1]);
char d1 = str[2].charAt(0);
str = br.readLine().split(" ");
int x2 = Integer.parseInt(str[0]);
int y2 = Integer.parseInt(str[1]);
char d2 = str[2].charAt(0);
if(x1==x2){
if(y1<y2)
out.println(d1=='U'&&d2=='D'?"Yes":"No");
else
out.println(d1=='D'&&d2=='U'?"Yes":"No");
}
else if(y1==y2){
if(x1<x2)
out.println(d1=='R'&&d2=='L'?"Yes":"No");
else
out.println(d1=='L'&&d2=='R'?"Yes":"No");
}
else{
if((d1=='U'||d1=='D')&&(d2=='U'||d2=='D'))
out.println("No");
else if((d1=='L'||d1=='R')&&(d2=='L'||d2=='R'))
out.println("No");
else{
int x3 = d1=='U'||d1=='D'?x1:x2;
int y3 = d1=='L'||d1=='R'?y1:y2;
if(x1<x3&&d1=='R'){
if(y2<y3&&d2=='U')
out.println(
x3-x1==y3-y2?"Yes":"No");
else if(y2>y3&&d2=='D')
out.println(
x3-x1==y2-y3?"Yes":"No");
else
out.println("No");
}
else if(x3<x1&&d1=='L'){
if(y2<y3&&d2=='U')
out.println(
x1-x3==y3-y2?"Yes":"No");
else if(y2>y3&&d2=='D')
out.println(
x1-x3==y2-y3?"Yes":"No");
else
out.println("No");
}
else if(y1<y3&&d1=='U'){
if(x2<x3&&d2=='R')
out.println(
x3-x2==y3-y1?"Yes":"No");
else if(x2>x3&&d2=='L')
out.println(
x2-x3==y3-y1?"Yes":"No");
else
out.println("No");
}
else if(y1>y3&&d1=='D'){
if(x2<x3&&d2=='R')
out.println(
x3-x2==y1-y3?"Yes":"No");
else if(x2>x3&&d2=='L')
out.println(
x2-x3==y1-y3?"Yes":"No");
else
out.println("No");
}
else
out.println("No");
}
}
}
br.close();
out.close();
}
}