結果

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

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
template <typename T> using min_priority_queue = priority_queue<T,vector<T>,greater<T>>;

template<typename T>
void printv(vector<T> &v){
    bool b = false;
    for(auto i : v){
        if(b) cout << " ";
        else b = true;
        cout << i;
    }
    cout << endl;
}

template <typename T>
bool chmin(T &a, const T& b) {
    if (a > b) {
        a = b;  // aをbで更新
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T &a, const T& b) {
    if (a < b) {
        a = b;  // aをbで更新
        return true;
    }
    return false;
}

void yn(bool b){
    if(b) cout << "Yes" << endl;
    else cout << "No" << endl;
}

bool debug;
bool randomInput;
void input(){
    if(debug && randomInput){
        
    }
    else{
        
    }
    return;
}

void calc(){
    vector<vector<int>> dir = {{1,0},{0,1},{-1,0},{0,-1}};
    map<char,int> mp;
    mp['D'] = 0;
    mp['R'] = 1;
    mp['U'] = 2;
    mp['L'] = 3;
    int T; cin >> T;
    for(int i = 0; i < T; i++){
        int x1, y1;
        int x2, y2;
        char d1, d2;
        cin >> x1 >> y1 >> d1;
        cin >> x2 >> y2 >> d2;
        swap(x1, y1);
        swap(x2, y2);
        x1 *= -1;
        x2 *= -1;
        int a1 = mp[d1];
        int a2 = mp[d2];
        if(d1 == d2){
            cout << "No" << endl;
            continue;
        }
        if(a1 > a2){
            swap(x1, x2);
            swap(y1, y2);
            swap(a1, a2);
        }

        if(a1%2 == 1 && a2%2 == 1){
            if(x1 != x2){
                cout << "No" << endl;
            }
            else if(y1 < y2) {
                cout << "Yes" << endl;
            }
            else{
                cout << "No" << endl;
            }
            continue;
        }

        if(a1%2 == 0 && a2%2 == 0){
            if(y1 != y2){
                cout << "No" << endl;
            }
            else if(x1 < x2){
                cout << "Yes" << endl;
            }
            else{
                cout << "No" << endl;
            }
            continue;
        }

        if(a1 == 0 && a2 == 1){
            int l1 = x2-x1;
            int l2 = y1-y2;
            if(l1 == l2 && l1 > 0){
                cout << "Yes" << endl;
            }
            else{
                cout << "No" << endl;
            }
            continue;
        }

        if(a1 == 0 && a2 == 3){
            int l1 = x2-x1;
            int l2 = y2-y1;
            if(l1 == l2 && l1 > 0){
                cout << "Yes" << endl;
            }
            else{
                cout << "No" << endl;
            }
            continue;
        }

        if(a1 == 1 && a2 == 2){
            int l1 = y2-y1;
            int l2 = x2-x1;
            if(l1 == l2 && l1 > 0){
                cout << "Yes" << endl;
            }
            else{
                cout << "No" << endl;
            }
            continue;
        }

        if(a1 == 2 && a2 == 3){
            int l1 = x1-x2;
            int l2 = y2-y1;
            if(l1 == l2 && l1 > 0){
                cout << "Yes" << endl;
            }
            else{
                cout << "No" << endl;
            }
            continue;
        }
    }
    return;
}

int64_t ansSimple;
void calcSimple(){
    return;
}

void calc1(){
    int t; cin >> t;
    for(int i = 0; i < t; i++){
        input();
        calc();
        calcSimple();
    }
}

int main(){
    debug = 0;
    randomInput = 0;
    srand(time(NULL));
    cout << fixed << setprecision(12);
    if(debug){
        calc1();
    }
    else{
        input();
        calc();
    }
    return 0;
}
//
0