結果

問題 No.2564 衝突予測
ユーザー t98slidert98slider
提出日時 2023-12-02 15:20:28
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,997 bytes
コンパイル時間 1,930 ms
コンパイル使用メモリ 192,552 KB
最終ジャッジ日時 2025-02-18 04:27:29
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 4 WA * 5
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

template<class T> ostream& operator << (ostream& os, const vector<T>& vec) {
    if(vec.empty()) return os;
    os << vec[0];
    for(auto it = vec.begin(); ++it != vec.end(); ) os << ' ' << *it;
    return os;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int T;
    cin >> T;
    while(T--){
        ll x1, y1, x2, y2;
        char c1, c2;
        cin >> x1 >> y1 >> c1 >> x2 >> y2 >> c2;
        if(c1 == c2){
            cout << "No\n";
            continue;
        }
        if((c1 == 'L' && c2 == 'R') || (c1 == 'R' && c2 == 'L')){
            cout << (y1 == y2 ? "Yes" : "No") << '\n';
            continue;
        }
        if((c1 == 'U' && c2 == 'D') || (c1 == 'D' && c2 == 'U')){
            cout << (x1 == x2 ? "Yes" : "No") << '\n';
            continue;
        }
        if(c2 == 'L' || c2 == 'R'){
            swap(x1, x2);
            swap(y1, y2);
            swap(c1, c2);
        }

        if(c1 == 'L' && c2 == 'U'){
            if(x2 < x1 && y2 < y1){
                cout << (abs(x1 - x2) == abs(y1 - y2) ? "Yes" : "No") << '\n';
            }else{
                cout << "No\n";
            }
            continue;
        }

        if(c1 == 'L' && c2 == 'D'){
            if(x2 < x1 && y2 > y1){
                cout << (abs(x1 - x2) == abs(y1 - y2) ? "Yes" : "No") << '\n';
            }else{
                cout << "No\n";
            }
            continue;
        }

        if(c1 == 'R' && c2 == 'U'){
            if(x2 > x1 && y2 < y1){
                cout << (abs(x1 - x2) == abs(y1 - y2) ? "Yes" : "No") << '\n';
            }else{
                cout << "No\n";
            }
            continue;
        }

        if(c1 == 'R' && c2 == 'D'){
            if(x2 > x1 && y2 > y1){
                cout << (abs(x1 - x2) == abs(y1 - y2) ? "Yes" : "No") << '\n';
            }else{
                cout << "No\n";
            }
            continue;
        }
    }
}
0