結果

問題 No.2564 衝突予測
ユーザー twooimp2twooimp2
提出日時 2023-12-02 15:58:12
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 419 ms / 2,000 ms
コード長 1,007 bytes
コンパイル時間 2,319 ms
コンパイル使用メモリ 208,180 KB
実行使用メモリ 6,548 KB
最終ジャッジ日時 2023-12-02 15:58:22
合計ジャッジ時間 7,261 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,548 KB
testcase_01 AC 2 ms
6,548 KB
testcase_02 AC 2 ms
6,548 KB
testcase_03 AC 411 ms
6,548 KB
testcase_04 AC 409 ms
6,548 KB
testcase_05 AC 414 ms
6,548 KB
testcase_06 AC 409 ms
6,548 KB
testcase_07 AC 411 ms
6,548 KB
testcase_08 AC 419 ms
6,548 KB
testcase_09 AC 407 ms
6,548 KB
testcase_10 AC 409 ms
6,548 KB
testcase_11 AC 404 ms
6,548 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;

int main(){
  ll t;
  cin>>t;
  while(t--){
    vector<ld> x(2),y(2);
    vector<char> d(2);
    for(ll i=0;i<2;i++){
      cin>>x[i]>>y[i]>>d[i];
    }
    vector<vector<ld>> dir(2,vector<ld>(2));
    for(ll i=0;i<2;i++){
      if(d[i]=='R'){
        dir[i][0]=1;
        dir[i][1]=0;
      }else if(d[i]=='L'){
        dir[i][0]=-1;
        dir[i][1]=0;
      }else if(d[i]=='U'){
        dir[i][0]=0;
        dir[i][1]=1;
      }else{
        dir[i][0]=0;
        dir[i][1]=-1;
      }
    }
    bool ok=false;
    if(dir[1][0]!=dir[0][0]){
      ld k=(x[0]-x[1])/(dir[1][0]-dir[0][0]);
      if(k>=0&&(y[0]-y[1])==k*(dir[1][1]-dir[0][1])){
        ok=true;
      }
    }
    if(dir[1][1]!=dir[0][1]){
      ld k=(y[0]-y[1])/(dir[1][1]-dir[0][1]);
      if(k>=0&&(x[0]-x[1])==k*(dir[1][0]-dir[0][0])){
        ok=true;
      }
    }
    if(ok){
      cout<<"Yes"<<endl;
    }else{
      cout<<"No"<<endl;
    }
  }
}
0