結果

問題 No.2564 衝突予測
ユーザー shihakashihaka
提出日時 2023-12-02 15:58:29
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,605 bytes
コンパイル時間 2,279 ms
コンパイル使用メモリ 212,656 KB
実行使用メモリ 6,656 KB
最終ジャッジ日時 2023-12-02 15:58:41
合計ジャッジ時間 6,333 ms
ジャッジサーバーID
(参考情報)
judge11 / judge9
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); i++)
template<typename T> inline bool chmax(T &a, T b) {return ((a < b) ? (a = b, true) : (false));}
template<typename T> inline bool chmin(T &a, T b) {return ((a > b) ? (a = b, true) : (false));}
typedef long long ll;
typedef pair<ll,ll> P;



int main() {
    ll t;
    cin >> t;
    vector<ll> x(2*t), y(2*t);
    vector<char> d(2*t);
    rep(i,2*t) cin >> x[i] >> y[i] >> d[i];

    rep(i,t) {
        ll ex = 0, ey = 0;
        set<ll> st_x, st_y;
        if(d[2*i] == 'U' || d[2*i] == 'D') {
            ex = x[2*i];
            st_x.insert(ex);
        }
        if(d[2*i] == 'L' || d[2*i] == 'R') {
            ey = y[2*i];
            st_y.insert(ey);
        }
        if(d[2*i+1] == 'U' || d[2*i+1] == 'D') {
            ex = x[2*i+1];
            st_x.insert(ex);
        }
        if(d[2*i+1] == 'L' || d[2*i+1] == 'R') {
            ey = y[2*i+1];
            st_y.insert(ey);
        }

        if(st_x.size() > 1 || st_y.size() > 1) {
            cout << "No" << endl;
        }
        else if(st_x.size() == 0 || st_y.size() == 0) {
            if(d[2*i] != d[2*i+1]) {
                cout << "Yes" << endl;
            }
            else {
                cout << "No" << endl;
            }
        }
        else {
            ll t1 = abs(x[2*i]-ex) + abs(y[2*i]-ey);
            ll t2 = abs(x[2*i+1]-ex) + abs(y[2*i+1]-ey);
            if(t1 == t2) {
                if(d[2*i] == 'R' && ex < x[2*i]) {
                    cout << "No" << endl;
                }
                else if(d[2*i] == 'L' && ex > x[2*i]) {
                    cout << "No" << endl;
                }
                else if(d[2*i] == 'U' && ey < y[2*i]) {
                    cout << "No" << endl;
                }
                else if(d[2*i] == 'D' && ey > y[2*i]) {
                    cout << "No" << endl;
                }
                else if(d[2*i+1] == 'R' && ex < x[2*i+1]) {
                    cout << "No" << endl;
                }
                else if(d[2*i+1] == 'L' && ex > x[2*i+1]) {
                    cout << "No" << endl;
                }
                else if(d[2*i+1] == 'U' && ey < y[2*i+1]) {
                    cout << "No" << endl;
                }
                else if(d[2*i+1] == 'D' && ey > y[2*i+1]) {
                    cout << "No" << endl;
                }
                else {
                    cout << "Yes" << endl;
                }

            }
            else {
                cout << "No" << endl;
            }
        }
    }


    return 0;
}
0