結果

問題 No.2564 衝突予測
ユーザー MMMM
提出日時 2023-12-02 15:47:03
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 326 ms / 2,000 ms
コード長 1,267 bytes
コンパイル時間 3,850 ms
コンパイル使用メモリ 229,724 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2023-12-02 15:47:12
合計ジャッジ時間 7,847 ms
ジャッジサーバーID
(参考情報)
judge10 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 316 ms
6,676 KB
testcase_04 AC 316 ms
6,676 KB
testcase_05 AC 320 ms
6,676 KB
testcase_06 AC 315 ms
6,676 KB
testcase_07 AC 317 ms
6,676 KB
testcase_08 AC 316 ms
6,676 KB
testcase_09 AC 326 ms
6,676 KB
testcase_10 AC 317 ms
6,676 KB
testcase_11 AC 316 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#include<atcoder/all>
#define chmin(x,y) (x) = min((x),(y))
#define chmax(x,y) (x) = max((x),(y))
#define ld long double
using namespace std;
using namespace atcoder;
using ll = long long;
const ll mod = 998244353;
using mint = modint998244353;
using Graph = vector<vector<int>>;
const vector<int> dx = {1,0,-1,0}, dy = {0,1,0,-1};

int main(){
  int T; cin >> T;
  while(T--){
    // input
    int x1,x2,y1,y2; char d1,d2;
    cin >> x1 >> y1 >> d1;
    cin >> x2 >> y2 >> d2;
    // prep
    if(d1 > d2){
      swap(x1,x2);
      swap(y1,y2);
      swap(d1,d2);
    }
    // solve
    bool crash = 0;
    if(d1 == 'L' && d2 == 'R'){
    	if(y1 == y2 && x1 > x2) crash = 1;
    }
    else if(d1 == 'D' && d2 == 'U') {
    	if(x1 == x2 && y1 > y2) crash = 1;
    }
    else if(d1 != d2){
      int X,Y,t1 = -1, t2 = -1;
      if(d1 == 'D'){
        X = x1, Y = y2;
        t1 = y1-Y, t2 = (X-x2) * (d2 == 'R' ? 1 : -1) ;
      } else { // then d2 == 'U' and d1 == 'L'/'R'
        X = x2, Y = y1;
        t1 = (X-x1) * (d1 == 'R' ? 1 : -1), t2 = Y-y2;
      }
      if(t1 == t2 && t1 > 0) crash = 1;
      
      //cout << X << " " << Y << " " << t1 << " " << t2 << endl;
    }
    // output
    cout << (crash ? "Yes" : "No") << endl;
  }
}
  
0