結果
| 問題 | No.2564 衝突予測 | 
| コンテスト | |
| ユーザー |  MM | 
| 提出日時 | 2023-12-02 15:47:03 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 330 ms / 2,000 ms | 
| コード長 | 1,267 bytes | 
| コンパイル時間 | 3,899 ms | 
| コンパイル使用メモリ | 228,696 KB | 
| 実行使用メモリ | 5,376 KB | 
| 最終ジャッジ日時 | 2024-09-26 19:17:00 | 
| 合計ジャッジ時間 | 7,993 ms | 
| ジャッジサーバーID (参考情報) | judge4 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 9 | 
ソースコード
#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;
  }
}
  
            
            
            
        