結果

問題 No.2564 衝突予測
ユーザー Preds1dentPreds1dent
提出日時 2023-12-02 15:32:55
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,458 bytes
コンパイル時間 1,927 ms
コンパイル使用メモリ 98,404 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2023-12-02 15:33:01
合計ジャッジ時間 5,460 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 1 ms
6,676 KB
testcase_02 AC 1 ms
6,676 KB
testcase_03 AC 292 ms
6,676 KB
testcase_04 AC 291 ms
6,676 KB
testcase_05 AC 308 ms
6,676 KB
testcase_06 AC 288 ms
6,676 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'bool solve()':
main.cpp:35:3: warning: 'd2' may be used uninitialized [-Wmaybe-uninitialized]
   35 |   if (d1 == 1 and d2 == 3 and y1 == y2 and x1 < x2) { return true; }
      |   ^~
main.cpp:13:11: note: 'd2' was declared here
   13 |   int d1, d2;
      |           ^~
main.cpp:37:15: warning: 'd1' may be used uninitialized [-Wmaybe-uninitialized]
   37 |   if (d1 == 0 and d2 == 3 and y2 - y1 == x2 - x1) return true;
      |       ~~~~~~~~^~~~~~~~~~~
main.cpp:13:7: note: 'd1' was declared here
   13 |   int d1, d2;
      |       ^~

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <string>
using namespace std;
string s = "URDL";
bool solve() {
  int x1, y1; cin >> x1 >> y1;
  char dd1; cin >> dd1;
  int d1, d2;
  int x2, y2; cin >> x2 >> y2;
  char dd2; cin >> dd2;
  for (int k = 0; k < 4; k++) {
    if (dd1 == s[k]) {
      d1 = k;
    }
    if (dd2 == s[k]) {
      d2 = k;
    }
  }
  if (d1 == d2) {
    return false;
  }
  if (d1 == 0 and d2 == 2 and x1 == x2 and y1 < y2) { return true; }
  if (d1 == 1 and d2 == 3 and y1 == y2 and x1 < x2) { return true; }
  if (d1 == 0 and d2 == 1 and y2 - y1 == x1 - x2) return true;
  if (d1 == 0 and d2 == 3 and y2 - y1 == x2 - x1) return true;
  if (d1 == 1 and d2 == 2 and x2 - x1 == y2 - y1) return true;
  if (d1 == 2 and d2 == 3 and x2 - x1 == y1 - y2) return true;
  swap(d1, d2), swap(x1, x2), swap(y1, y2);
  if (d1 == 0 and d2 == 2 and x1 == x2 and y1 < y2) { return true; }
  if (d1 == 1 and d2 == 3 and y1 == y2 and x1 < x2) { return true; }
  if (d1 == 0 and d2 == 1 and y2 - y1 == x1 - x2) return true;
  if (d1 == 0 and d2 == 3 and y2 - y1 == x2 - x1) return true;
  if (d1 == 1 and d2 == 2 and x2 - x1 == y2 - y1) return true;
  if (d1 == 2 and d2 == 3 and x2 - x1 == y1 - y2) return true;
  return false;
}
int main() {
  int t; cin >> t;
  while (t--) {
    if (solve()) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }

}

0