結果
| 問題 | No.2564 衝突予測 | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2023-12-02 17:53:37 | 
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 59 ms / 2,000 ms | 
| コード長 | 1,885 bytes | 
| コンパイル時間 | 4,118 ms | 
| コンパイル使用メモリ | 247,720 KB | 
| 最終ジャッジ日時 | 2025-02-18 06:03:04 | 
| ジャッジサーバーID (参考情報) | judge3 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 9 | 
ソースコード
#include <bits/stdc++.h>
#include <bits/extc++.h>
using i64 = long long;
void solve()
{
    using T = std::tuple<i64, i64, char>;
    T a[2];
    for (int i = 0; i < 2; i++)
    {
        auto &[x, y, ch] = a[i];
        std::cin >> x >> y >> ch;
    }
    auto check = [&](T a, T b)
    {
        auto &[x1, y1, c1] = a;
        auto &[x2, y2, c2] = b;
        bool ok = (std::llabs(x1 - x2) == std::llabs(y1 - y2));
        if (c1 == 'R')
        {
            if (c2 == 'L' && y1 == y2 && x1 < x2)
                return true;
            if (c2 == 'U' && x1 < x2 && y1 > y2 && ok)
                return true;
            if (c2 == 'D' && x1 < x2 && y1 < y2 && ok)
                return true;
        }
        if (c1 == 'L')
        {
            if (c2 == 'R' && y1 == y2 && x2 < x1)
                return true;
            if (c2 == 'U' && x1 > x2 && y1 > y2 && ok)
                return true;
            if (c2 == 'D' && x1 > x2 && y1 < y2 && ok)
                return true;
        }
        if (c1 == 'D')
        {
            if (c2 == 'U' && x1 == x2 && y1 > y2)
                return true;
            if (c2 == 'R' && x2 < x1 && y2 < y1 && ok)
                return true;
            if (c2 == 'L' && x2 > x1 && y2 < y1 && ok)
                return true;
        }
        if (c1 == 'U')
        {
            if (c2 == 'D' && x1 == x2 && y1 < y2)
                return true;
            if (c2 == 'R' && x2 < x1 && y2 > y1 && ok)
                return true;
            if (c2 == 'L' && x1 < x2 && y2 > y1 && ok)
                return true;
        }
        return false;
    };
    if (check(a[0], a[1]))
    {
        std::cout << "Yes\n";
    }
    else
    {
        std::cout << "No\n";
    }
}
int main()
{
    std::cin.tie(nullptr)->sync_with_stdio(false);
    int t;
    std::cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}
            
            
            
        