結果
問題 | No.2564 衝突予測 |
ユーザー | shihaka(C_plplplpl) |
提出日時 | 2023-12-02 16:45:34 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 329 ms / 2,000 ms |
コード長 | 4,273 bytes |
コンパイル時間 | 2,450 ms |
コンパイル使用メモリ | 205,948 KB |
実行使用メモリ | 6,528 KB |
最終ジャッジ日時 | 2024-09-26 20:41:02 |
合計ジャッジ時間 | 5,978 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | AC | 3 ms
5,376 KB |
testcase_02 | AC | 2 ms
5,376 KB |
testcase_03 | AC | 329 ms
6,528 KB |
testcase_04 | AC | 315 ms
6,528 KB |
testcase_05 | AC | 310 ms
6,528 KB |
testcase_06 | AC | 315 ms
6,528 KB |
testcase_07 | AC | 307 ms
6,528 KB |
testcase_08 | AC | 310 ms
6,528 KB |
testcase_09 | AC | 305 ms
6,528 KB |
testcase_10 | AC | 306 ms
6,528 KB |
testcase_11 | AC | 306 ms
6,528 KB |
ソースコード
#include <bits/stdc++.h> using namespace std; #define rep(i,n) for (int i = 0; i < (n); i++) template<typename T> inline bool chmax(T &a, T b) {return ((a < b) ? (a = b, true) : (false));} template<typename T> inline bool chmin(T &a, T b) {return ((a > b) ? (a = b, true) : (false));} typedef long long ll; typedef pair<ll,ll> P; int main() { ll t; cin >> t; vector<ll> x(2*t), y(2*t); vector<char> d(2*t); rep(i,2*t) cin >> x[i] >> y[i] >> d[i]; rep(i,t) { ll p1 = 2*i, p2 = 2*i+1; if(d[p1] == 'R') { if(d[p2] == 'R') { cout << "No" << endl; } if(d[p2] == 'L') { if(x[p1] < x[p2] && y[p1] == y[p2]) { cout << "Yes" << endl; } else { cout << "No" << endl; } } if(d[p2] == 'U') { ll dx = x[p2]-x[p1], dy = y[p1]-y[p2]; if(dx > 0 && dx == dy) { cout << "Yes" << endl; } else { cout << "No" << endl; } } if(d[p2] == 'D') { ll dx = x[p2]-x[p1], dy = y[p2]-y[p1]; if(dx > 0 && dx == dy) { cout << "Yes" << endl; } else { cout << "No" << endl; } } } if(d[p1] == 'L') { if(d[p2] == 'R') { if(x[p1] > x[p2] && y[p1] == y[p2]) { cout << "Yes" << endl; } else { cout << "No" << endl; } } if(d[p2] == 'L') { cout << "No" << endl; } if(d[p2] == 'U') { ll dx = x[p1]-x[p2], dy = y[p1]-y[p2]; if(dx > 0 && dx == dy) { cout << "Yes" << endl; } else { cout << "No" << endl; } } if(d[p2] == 'D') { ll dx = x[p1]-x[p2], dy = y[p2]-y[p1]; if(dx > 0 && dx == dy) { cout << "Yes" << endl; } else { cout << "No" << endl; } } } if(d[p1] == 'U') { if(d[p2] == 'R') { ll dx = x[p1]-x[p2], dy = y[p2]-y[p1]; if(dx > 0 && dx == dy) { cout << "Yes" << endl; } else { cout << "No" << endl; } } if(d[p2] == 'L') { ll dx = x[p2]-x[p1], dy = y[p2]-y[p1]; if(dx > 0 && dx == dy) { cout << "Yes" << endl; } else { cout << "No" << endl; } } if(d[p2] == 'U') { cout << "No" << endl; } if(d[p2] == 'D') { if(x[p1] == x[p2] && y[p1] < y[p2]) { cout << "Yes" << endl; } else { cout << "No" << endl; } } } if(d[p1] == 'D') { if(d[p2] == 'R') { ll dx = x[p1]-x[p2], dy = y[p1]-y[p2]; if(dx > 0 && dx == dy) { cout << "Yes" << endl; } else { cout << "No" << endl; } } if(d[p2] == 'L') { ll dx = x[p2]-x[p1], dy = y[p1]-y[p2]; if(dx > 0 && dx == dy) { cout << "Yes" << endl; } else { cout << "No" << endl; } } if(d[p2] == 'U') { if(x[p1] == x[p2] && y[p1] > y[p2]) { cout << "Yes" << endl; } else { cout << "No" << endl; } } if(d[p2] == 'D') { cout << "No" << endl; } } } return 0; }