結果

問題 No.2564 衝突予測
ユーザー しょうゆ団子
提出日時 2025-02-12 03:44:17
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 899 bytes
コンパイル時間 3,597 ms
コンパイル使用メモリ 275,096 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2025-02-12 03:44:25
合計ジャッジ時間 7,071 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other WA * 9
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:29:18: warning: ‘d1’ may be used uninitialized [-Wmaybe-uninitialized]
   29 |         if (dy[d1] != dy[d2]) {
      |             ~~~~~^
main.cpp:14:13: note: ‘d1’ was declared here
   14 |         int d1, d2;
      |             ^~
main.cpp:29:28: warning: ‘d2’ may be used uninitialized [-Wmaybe-uninitialized]
   29 |         if (dy[d1] != dy[d2]) {
      |                       ~~~~~^
main.cpp:14:17: note: ‘d2’ was declared here
   14 |         int d1, d2;
      |                 ^~

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

const int dy[4] = {1, 0, -1, 0}, dx[4] = {0, 1, 0, -1};

int main() {
    int T;
    cin >> T;
    while (T--) {
        int x1, y1, x2, y2;
        char c1, c2;
        cin >> x1 >> y1 >> c1 >> x2 >> y2 >> c2;
        int d1, d2;
        if (c1 == 'U') d1 = 0;
        if (c1 == 'R') d1 = 1;
        if (c1 == 'D') d1 = 2;
        if (c1 == 'L') d1 = 3;
        if (c2 == 'U') d2 = 0;
        if (c2 == 'R') d2 = 1;
        if (c2 == 'D') d2 = 2;
        if (c2 == 'L') d2 = 3;
        bool ok = true;
        if (dx[d1] != dx[d2]) {
            ok &= (dx[d1] - dx[d2]) * (x1 - x2) <= 0;
        } else {
            ok &= x1 == x2;
        }
        if (dy[d1] != dy[d2]) {
            ok &= (dy[d1] - dy[d2]) * (y1 - y2) <= 0;
        } else {
            ok &= y1 == y2;
        }
        cout << (ok ? "Yes" : "No") << endl;
    }
    return 0;
}
0