結果
| 問題 |
No.2564 衝突予測
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-12-02 15:22:17 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 60 ms / 2,000 ms |
| コード長 | 2,281 bytes |
| コンパイル時間 | 3,215 ms |
| コンパイル使用メモリ | 194,348 KB |
| 最終ジャッジ日時 | 2025-02-18 04:30:31 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 9 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) {
if(vec.empty()) return os;
os << vec[0];
for(auto it = vec.begin(); ++it != vec.end(); ) os << ' ' << *it;
return os;
}
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
int T;
cin >> T;
while(T--){
ll x1, y1, x2, y2;
char c1, c2;
cin >> x1 >> y1 >> c1 >> x2 >> y2 >> c2;
if(c1 == c2){
cout << "No\n";
continue;
}
if((c1 == 'L' && c2 == 'R') || (c1 == 'R' && c2 == 'L')){
if(c2 == 'R'){
swap(x1, x2);
swap(y1, y2);
swap(c1, c2);
}
cout << (x1 < x2 && y1 == y2 ? "Yes" : "No") << '\n';
continue;
}
if((c1 == 'U' && c2 == 'D') || (c1 == 'D' && c2 == 'U')){
if(c2 == 'U'){
swap(x1, x2);
swap(y1, y2);
swap(c1, c2);
}
cout << (y1 < y2 && x1 == x2 ? "Yes" : "No") << '\n';
continue;
}
if(c2 == 'L' || c2 == 'R'){
swap(x1, x2);
swap(y1, y2);
swap(c1, c2);
}
if(c1 == 'L' && c2 == 'U'){
if(x2 < x1 && y2 < y1){
cout << (abs(x1 - x2) == abs(y1 - y2) ? "Yes" : "No") << '\n';
}else{
cout << "No\n";
}
continue;
}
if(c1 == 'L' && c2 == 'D'){
if(x2 < x1 && y2 > y1){
cout << (abs(x1 - x2) == abs(y1 - y2) ? "Yes" : "No") << '\n';
}else{
cout << "No\n";
}
continue;
}
if(c1 == 'R' && c2 == 'U'){
if(x2 > x1 && y2 < y1){
cout << (abs(x1 - x2) == abs(y1 - y2) ? "Yes" : "No") << '\n';
}else{
cout << "No\n";
}
continue;
}
if(c1 == 'R' && c2 == 'D'){
if(x2 > x1 && y2 > y1){
cout << (abs(x1 - x2) == abs(y1 - y2) ? "Yes" : "No") << '\n';
}else{
cout << "No\n";
}
continue;
}
}
}