結果
問題 | No.2564 衝突予測 |
ユーザー | viral8 |
提出日時 | 2023-12-02 15:18:40 |
言語 | Java21 (openjdk 21) |
結果 |
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 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 54 ms
36,992 KB |
testcase_01 | AC | 54 ms
36,568 KB |
testcase_02 | AC | 53 ms
37,020 KB |
testcase_03 | AC | 561 ms
46,428 KB |
testcase_04 | AC | 564 ms
46,404 KB |
testcase_05 | AC | 562 ms
46,148 KB |
testcase_06 | AC | 560 ms
46,500 KB |
testcase_07 | AC | 566 ms
46,412 KB |
testcase_08 | AC | 566 ms
46,500 KB |
testcase_09 | AC | 556 ms
46,288 KB |
testcase_10 | AC | 562 ms
46,132 KB |
testcase_11 | AC | 549 ms
45,904 KB |
ソースコード
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(); } }