結果

問題 No.2564 衝突予測
ユーザー takumi152takumi152
提出日時 2023-12-02 15:30:40
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 188 ms / 2,000 ms
コード長 1,851 bytes
コンパイル時間 859 ms
コンパイル使用メモリ 105,868 KB
実行使用メモリ 8,704 KB
最終ジャッジ日時 2023-12-02 15:30:44
合計ジャッジ時間 3,509 ms
ジャッジサーバーID
(参考情報)
judge14 / 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 168 ms
8,704 KB
testcase_04 AC 167 ms
8,704 KB
testcase_05 AC 169 ms
8,704 KB
testcase_06 AC 167 ms
8,704 KB
testcase_07 AC 167 ms
8,704 KB
testcase_08 AC 166 ms
8,704 KB
testcase_09 AC 164 ms
8,704 KB
testcase_10 AC 188 ms
8,704 KB
testcase_11 AC 166 ms
8,704 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <queue>
#include <stack>
#include <unordered_set>
#include <unordered_map>

using namespace std;

typedef long long int ll;
typedef pair<int, int> Pii;

const ll mod = 998244353;

struct problem {
  int x1, y1;
  char d1;
  int x2, y2;
  char d2;
};

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  int t;
  cin >> t;
  vector<problem> problems(t);
  for (auto &p: problems) {
    cin >> p.x1 >> p.y1 >> p.d1;
    cin >> p.x2 >> p.y2 >> p.d2;
  }

  vector<string> ans(t);
  for (int i = 0; i < t; i++) {
    auto p = problems[i];
    if (p.d1 == p.d2) {
      ans[i] = "No";
    }
    else if (p.d1 == 'R' && p.d2 == 'L') {
      ans[i] = (p.y1 == p.y2 && p.x1 < p.x2) ? "Yes" : "No";
    }
    else if (p.d1 == 'L' && p.d2 == 'R') {
      ans[i] = (p.y1 == p.y2 && p.x1 > p.x2) ? "Yes" : "No";
    }
    else if (p.d1 == 'U' && p.d2 == 'D') {
      ans[i] = (p.x1 == p.x2 && p.y1 < p.y2) ? "Yes" : "No";
    }
    else if (p.d1 == 'D' && p.d2 == 'U') {
      ans[i] = (p.x1 == p.x2 && p.y1 > p.y2) ? "Yes" : "No";
    }
    else if ((p.d1 == 'R' && p.d2 == 'U') || (p.d1 == 'D' && p.d2 == 'L')) {
      ans[i] = (p.x1 + p.y1 == p.x2 + p.y2 && p.x1 < p.x2) ? "Yes" : "No";
    }
    else if ((p.d1 == 'L' && p.d2 == 'D') || (p.d1 == 'U' && p.d2 == 'R')) {
      ans[i] = (p.x1 + p.y1 == p.x2 + p.y2 && p.x1 > p.x2) ? "Yes" : "No";
    }
    else if ((p.d1 == 'R' && p.d2 == 'D') || (p.d1 == 'U' && p.d2 == 'L')) {
      ans[i] = (p.x1 - p.y1 == p.x2 - p.y2 && p.x1 < p.x2) ? "Yes" : "No";
    }
    else if ((p.d1 == 'L' && p.d2 == 'U') || (p.d1 == 'D' && p.d2 == 'R')) {
      ans[i] = (p.x1 - p.y1 == p.x2 - p.y2 && p.x1 > p.x2) ? "Yes" : "No";
    }
  }

  for (auto &x: ans) cout << x << endl;

  return 0;
}
0