結果

問題 No.2564 衝突予測
ユーザー momoyuu
提出日時 2023-12-15 14:20:19
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 59 ms / 2,000 ms
コード長 1,210 bytes
コンパイル時間 1,112 ms
コンパイル使用メモリ 92,868 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-09-27 06:22:45
合計ジャッジ時間 2,723 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 9
権限があれば一括ダウンロードができます

ソースコード

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