結果

問題 No.2564 衝突予測
ユーザー tenbatenba
提出日時 2023-12-02 16:21:38
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 320 ms / 2,000 ms
コード長 4,813 bytes
コンパイル時間 2,758 ms
コンパイル使用メモリ 104,232 KB
実行使用メモリ 6,548 KB
最終ジャッジ日時 2023-12-02 16:21:46
合計ジャッジ時間 5,229 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 316 ms
6,548 KB
testcase_04 AC 317 ms
6,548 KB
testcase_05 AC 320 ms
6,548 KB
testcase_06 AC 316 ms
6,548 KB
testcase_07 AC 319 ms
6,548 KB
testcase_08 AC 318 ms
6,548 KB
testcase_09 AC 320 ms
6,548 KB
testcase_10 AC 315 ms
6,548 KB
testcase_11 AC 316 ms
6,548 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

//(・ω・)
#include <stdio.h>
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, atoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <iomanip> //setprecision
#include <limits>
#include <sstream> //istringstream
#include <stdlib.h>
#include <list>
#include <iterator>//std::advance()
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define SZ(x) ((int)(x).size());
#define vec vector
template <class T>
using v = vector<T>;
template <class T>
using vv = v< v<T> >;
template <class T>
using vvv = v< vv<T> >;
#define el '\n'
#define vl v<ll>
#define vvl vv<ll>
#define pl pair<ll, ll>
#define repab(i, a, b) for(ll i = a; i < (ll)(b); ++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); ++i)
#define rep1(i, n) for(ll i = 1; i <= (ll)(n); ++i)
#define rrep(i, n) for(ll i = ((ll)(n) - 1); i >= 0; --i)
#define rrep1(i, n) for(ll i = ((ll)(n)); i > 0; --i)
#define YN(x) cout << ((x) ? "YES\n" : "NO\n");
#define Yn(x) cout << ((x) ? "Yes\n" : "No\n");
#define yn(x) cout << ((x) ? "yes\n" : "no\n");
#define COUT(x) cout << (x) << el;
const double pi = 3.141592653589793238;
const int inf = 1073741823;
const ll infl = 1LL << 60;

ll gcd(ll a, ll b){return b ? gcd(b, a % b) : a;}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号 (例) par[3] = 2 : 3の親が2
    
    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }
    
    int root(int x) { // データxが属する木の根を再帰で得る:root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }
    
    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時:xの根rxをyの根ryにつける
    }
    
    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main(){
    int t;
    cin >> t;
    for(int i = 0; i < t; ++i){
        string ans = "No";
        long long x1,y1,x2,y2;
        char d1,d2;
        cin >> x1 >> y1 >> d1 >> x2 >> y2 >> d2;
        if(x1 == x2){
            if(y1 < y2){
                if(d1 == 'U' &&  d2 == 'D') ans = "Yes";
            }else{
                if(d1 == 'D' &&  d2 == 'U') ans = "Yes";
            }
        }else if(y1 == y2){
            if(x1 < x2){
                if(d1 == 'R' &&  d2 == 'L') ans = "Yes";
            }else{
                if(d1 == 'L' &&  d2 == 'R') ans = "Yes";
            }
        }else{
            if(d1 == 'U' && d2 == 'L' || d1 == 'L' && d2 == 'U' || d1 == 'D' && d2 == 'R' || d1 == 'R' && d2 == 'D' || d1 == 'U' && d2 == 'R' || d1 == 'R' && d2 == 'U' || d1 == 'D' && d2 == 'L' || d1 == 'L' && d2 == 'D'){
                long long x = x1 - x2;
                long long y = y1 - y2;
                if(x < 0 && y < 0){
                    if(d1 == 'R' || d2 == 'L'){
                        if(d1 == 'U' || d2 == 'D'){
                            if(abs(x) == abs(y)) ans = "Yes";
                        }
                    }
                }else if(x < 0 && y > 0){
                    if(d1 == 'R' || d2 == 'L'){
                        if(d1 == 'D' || d2 == 'U'){
                            if(abs(x) == abs(y)) ans = "Yes";
                        }
                    }
                }else if(x > 0 && y < 0){
                    if(d1 == 'L' || d2 == 'R'){
                        if(d1 == 'U' || d2 == 'D'){
                            if(abs(x) == abs(y)) ans = "Yes";
                        }
                    }
                }else{
                    if(d1 == 'L' || d2 == 'R'){
                        if(d1 == 'D' || d2 == 'U'){
                            if(abs(x) == abs(y)) ans = "Yes";
                        }
                    }
                }
            }
        }
        cout << ans << endl;
    }


    return 0;
}
0