結果
問題 |
No.2564 衝突予測
|
ユーザー |
![]() |
提出日時 | 2023-12-02 17:00:18 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,215 bytes |
コンパイル時間 | 2,276 ms |
コンパイル使用メモリ | 193,140 KB |
最終ジャッジ日時 | 2025-02-18 05:50:34 |
ジャッジサーバーID (参考情報) |
judge2 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 4 WA * 5 |
ソースコード
#include <bits/stdc++.h> //#include <atcoder/all> using namespace std; //using namespace atcoder; //using mint = modint1000000007; //const int mod = 1000000007; //using mint = modint998244353; //const int mod = 998244353; //const int INF = 1e9; //const long long LINF = 1e18; #define rep(i, n) for (int i = 0; i < (n); ++i) #define rep2(i,l,r)for(int i=(l);i<(r);++i) #define rrep(i, n) for (int i = (n-1); i >= 0; --i) #define rrep2(i,l,r)for(int i=(r-1);i>=(l);--i) #define all(x) (x).begin(),(x).end() #define allR(x) (x).rbegin(),(x).rend() #define endl "\n" #define P pair<int,int> template<typename A, typename B> inline bool chmax(A & a, const B & b) { if (a < b) { a = b; return true; } return false; } template<typename A, typename B> inline bool chmin(A & a, const B & b) { if (a > b) { a = b; return true; } return false; } int calc(int x, int y, int p, int q, char d) { if (x != p && y != q)return -1; if (x == p) { if (y <= q && d == 'U') { return abs(y - q); } if (y >= q && d == 'D') { return abs(y - q); } } if (y == q) { if (x <= p && d == 'R') { return abs(x - p); } if (x >= p && d == 'L') { return abs(x - p); } } return -1; } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int t; cin >> t; while (t--) { int x0, y0; char d0; cin >> x0 >> y0 >> d0; int x1, y1; char d1; cin >> x1 >> y1 >> d1; if (d0 == d1) { cout << "No" << endl; continue; } if (x0 == x1) { if (y0 > y1) { swap(y0, y1); swap(d0, d1); } if (d0 == 'U' && d1 == 'D') cout << "Yes" << endl; else cout << "No" << endl; continue; } if (y0 == y1) { if (x0 > x1) { swap(x0, x1); swap(d0, d1); } if (d0 == 'R' && d1 == 'L') cout << "Yes" << endl; continue; } { int x2 = x0; int y2 = y1; auto f0 = calc(x0, y0, x2, y2, d0); auto f1 = calc(x1, y1, x2, y2, d1); if (-1 != f0 && -1 != f1 && f0 == f1) { cout << "Yes" << endl; continue; } } { int x2 = x1; int y2 = y0; auto f0 = calc(x0, y0, x2, y2, d0); auto f1 = calc(x1, y1, x2, y2, d1); if (-1 != f0 && -1 != f1 && f0 == f1) { cout << "Yes" << endl; continue; } } cout << "No" << endl; } return 0; }