結果

問題 No.2564 衝突予測
ユーザー Feishi LiFeishi Li
提出日時 2023-12-02 16:36:24
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,040 bytes
コンパイル時間 4,116 ms
コンパイル使用メモリ 262,016 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2023-12-02 16:36:30
合計ジャッジ時間 5,731 ms
ジャッジサーバーID
(参考情報)
judge11 / judge10
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
#include <bits/extc++.h>
using i64 = long long;
void solve()
{
    using T = std::tuple<int, int, 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;
        if (c1 == 'R' && c2 == 'L')
        {
            if (y1 == y2 && x1 < x2)
            {
                return true;
            }
        }
        if (c1 == 'R' && (c2 == 'U' || c2 == 'D'))
        {
            if (x1 < x2 && std::abs(x1 - x2) == std::abs(y1 - y2))
            {
                return true;
            }
        }
        if (c1 == 'L' && c2 == 'R')
        {
            if (y1 == y2 && x1 > x2)
            {
                return true;
            }
        }
        if (c1 == 'L' && (c2 == 'D' || c2 == 'U'))
        {
            if (x2 < x1 && std::abs(x1 - x2) == std::abs(y1 - y2))
            {
                return true;
            }
        }

        if (c1 == 'D' && c2 == 'U')
        {
            if (x1 == x2 && y1 > y2)
            {
                return true;
            }
        }
        if (c1 == 'D' && (c2 == 'L' || c2 == 'R'))
        {
            if (y1 > y2 && std::abs(x1 - x2) == std::abs(y1 - y2))
            {
                return true;
            }
        }
        if (c1 == 'U' && c2 == 'D')
        {
            if (x1 == x2 && y1 < y2)
            {
                return true;
            }
        }
        if (c1 == 'U' && (c2 == 'L' || c2 == 'R'))
        {
            if (y1 < y2 && std::abs(x1 - x2) == std::abs(y1 - y2))
            {
                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;
}
0