結果
| 問題 |
No.2564 衝突予測
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-12-02 15:54:24 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 328 ms / 2,000 ms |
| コード長 | 2,784 bytes |
| コンパイル時間 | 4,429 ms |
| コンパイル使用メモリ | 242,028 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-09-26 19:29:46 |
| 合計ジャッジ時間 | 8,622 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 9 |
ソースコード
#include <cctype>
#include <string>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <bits/stdc++.h>
#include <atcoder/all>
#include <math.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using namespace atcoder;
using ll = long long;
using p = pair<int,int>;
using mod = modint998244353;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
vector<pair<char,int>> RunLength(string s){
vector<pair<char,int>> R;
int n = s.size();
int pre = 0;
rep(i,n - 1){
if(s[i + 1] != s[i]){
R.push_back({s[i],i - pre + 1});
pre = i + 1;
}
}
if(pre != n)R.push_back({s[n - 1],n - pre});
return R;
}
int op(int a,int b){return min(a,b);}
int e(){return (int)1e9;}
segtree<int,op,e> seg(1);
int n,m;
map<int,vector<int>> mp;
int bfs(int start,int goal){
queue<int> Q;
vector<int> seen(n,-1);
Q.push(start);
seen[start] = 0;
while(Q.size()){
int now = Q.front();Q.pop();
for(int next:mp[now]){
if(seen[next] != -1)continue;
seen[next] = seen[now] + 1;
Q.push(next);
if(next == goal)Q = {};
}
}
return seen[goal];
}
int main(){
int t;cin >> t;
while(t--){
int x1,x2,y1,y2;
char d1,d2;
cin >> x1 >> y1 >> d1;
cin >> x2 >> y2 >> d2;
if(d1 == d2){
cout << "No" << endl;
}else if((d1 == 'U' && d2 == 'D') || (d1 == 'D' && d2 == 'U') || (d1 == 'L' && d2 == 'R') || (d1 == 'R' && d2 == 'L')){
string ans = "No";
if(d1 == 'L' && d2 == 'R' && y1 == y2 && x2 <= x1)ans = "Yes";
if(d1 == 'R' && d2 == 'L' && y1 == y2 && x2 >= x1)ans = "Yes";
if(d1 == 'U' && d2 == 'D' && x1 == x2 && y2 >= y1)ans = "Yes";
if(d1 == 'D' && d2 == 'U' && x1 == x2 && y2 <= y1)ans = "Yes";
cout << ans << endl;
}else{
vector<int> L{0,0};
int k1,k2;
if(d1 == 'R' || d1 == 'L'){
L[0] = x2;
L[1] = y1;
k1 = L[0] - x1;
k2 = L[1] - y2;
if(d1 == 'L')k1 *= -1;
if(d2 == 'D')k2 *= -1;
}else{//d1 U or D
L[0] = x1;
L[1] = y2;
k1 = L[1] - y1;
k2 = L[0] - x2;
if(d1 == 'D')k1 *= -1;
if(d2 == 'L')k2 *= -1;
}
if(k1 >= 0 && k1 == k2){
cout << "Yes" << endl;
}else{
cout << "No" << endl;
}
}
}
}