結果

問題 No.2564 衝突予測
ユーザー momoyuumomoyuu
提出日時 2023-12-15 14:20:19
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 57 ms / 2,000 ms
コード長 1,210 bytes
コンパイル時間 905 ms
コンパイル使用メモリ 92,644 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2023-12-15 14:20:23
合計ジャッジ時間 3,330 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;
using ll = long long;

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

    int t;
    cin>>t;
    while(t--){
        ll a,b,c,d;
        char x,y;
        cin>>a>>b>>x>>c>>d>>y;
        if((x=='R'||x=='L')&&(y=='R'||y=='L')){
            if(b!=d) cout<<"No\n";
            else if(a<c&&x=='R'&&y=='L') cout<<"Yes\n";
            else if(c<a&&x=='L'&&y=='R') cout<<"Yes\n";
            else cout<<"No\n";
            continue;
        }else if((x=='U'||x=='D')&&(y=='U'||y=='D')){
            if(a!=c) cout<<"No\n";
            else if(b<d&&x=='U'&&y=='D') cout<<"Yes\n";
            else if(d<b&&x=='D'&&y=='U') cout<<"Yes\n";
            else cout<<"No\n";
        }else{
            if(x=='R'||x=='L'){
                swap(x,y);
                swap(a,c);
                swap(b,d);
            }
            ll n1 = -1e18;
            ll n2 = -1e17;
            if(x=='U'&&d>b) n1 = d - b;
            else if(x=='D'&&b>d) n1 = b - d;
            if(y=='R'&&c<a) n2 = a - c;
            else if(y=='L'&&a<c) n2 = c - a;
            if(n1==n2) cout<<"Yes\n";
            else cout<<"No\n";
        }
    }
}
0