結果

問題 No.2564 衝突予測
ユーザー srjywrdnprkt
提出日時 2024-10-17 01:13:36
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 203 ms / 2,000 ms
コード長 922 bytes
コンパイル時間 2,065 ms
コンパイル使用メモリ 193,792 KB
最終ジャッジ日時 2025-02-24 20:02:27
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 9
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

void NO(){cout << "No" << endl;}
void YES(){cout << "Yes" << endl;}

void solve(){
    char c1, c2;
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> c1 >> x2 >> y2 >> c2;
    if (c1 > c2){
        swap(x1, x2);
        swap(y1, y2);
        swap(c1, c2);
    }
    if (c1 == 'D' && c2 == 'U' && x1 == x2 && y1 > y2) YES();
    else if (c1 == 'L' && c2 == 'R' && y1 == y2 && x1 > x2) YES();
    else if (c1 == 'D' && c2 == 'R' && x1 > x2 && y1-y2 == x1-x2) YES();
    else if (c1 == 'D' && c2 == 'L' && x1 < x2 && y1-y2 == x2-x1) YES();
    else if (c1 == 'L' && c2 == 'U' && x1 > x2 && y1-y2 == x1-x2) YES();
    else if (c1 == 'R' && c2 == 'U' && x1 < x2 && y1-y2 == x2-x1) YES();
    else NO();
}

int main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);

    int T;
    cin >> T;
    while(T--){
        solve();
    }

    return 0;
}
0