結果

問題 No.2564 衝突予測
ユーザー t98slidert98slider
提出日時 2023-12-02 15:22:17
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 56 ms / 2,000 ms
コード長 2,281 bytes
コンパイル時間 2,188 ms
コンパイル使用メモリ 202,548 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2023-12-02 15:22:21
合計ジャッジ時間 3,725 ms
ジャッジサーバーID
(参考情報)
judge9 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 1 ms
6,676 KB
testcase_02 AC 1 ms
6,676 KB
testcase_03 AC 54 ms
6,676 KB
testcase_04 AC 55 ms
6,676 KB
testcase_05 AC 52 ms
6,676 KB
testcase_06 AC 54 ms
6,676 KB
testcase_07 AC 53 ms
6,676 KB
testcase_08 AC 56 ms
6,676 KB
testcase_09 AC 51 ms
6,676 KB
testcase_10 AC 52 ms
6,676 KB
testcase_11 AC 51 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

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')){
            if(c2 == 'R'){
                swap(x1, x2);
                swap(y1, y2);
                swap(c1, c2);
            }
            cout << (x1 < x2 && y1 == y2 ? "Yes" : "No") << '\n';
            continue;
        }
        if((c1 == 'U' && c2 == 'D') || (c1 == 'D' && c2 == 'U')){
            if(c2 == 'U'){
                swap(x1, x2);
                swap(y1, y2);
                swap(c1, c2);
            }
            cout << (y1 < y2 && 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