結果
| 問題 |
No.2564 衝突予測
|
| コンテスト | |
| ユーザー |
lemon_math_tea
|
| 提出日時 | 2023-12-02 15:56:21 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 4,684 bytes |
| コンパイル時間 | 4,648 ms |
| コンパイル使用メモリ | 263,132 KB |
| 最終ジャッジ日時 | 2025-02-18 05:02:29 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 4 WA * 5 |
ソースコード
// コンパイルはctrl + shift + B
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
#define ll long long
#define all(x) (x).begin(), (x).end()
#define yes "Yes"
#define no "No"
// 最大公約数 O(log(N))
template<typename T>
T gcd(T a, T b) {
if (b == 0) return a;
else return gcd(b, a % b);
}
// 素数判定 O(sqrt(N))
bool is_prime(ll n) {
for (ll i = 2; i*i <= n; i++) {
if (n % i == 0) return false;
}
return true;
}
//n以下の素数求めマシーン O(Nloglog(N))
vector<ll> getprime(ll n) {
vector<ll> ans;
vector<bool> isprime(n + 1, true);
//0, 1はダメ
isprime[0] = false; isprime[1] = false;
//やる
for (int i = 2; i <= n; i++) {
if (!isprime[i]) continue;
ans.push_back(i);
for (int j = 2 * i; j <= n; j += i) {
//i以外のiの倍数をキャンセル
isprime[j] = false;
}
}
return ans;
}
// nを素因数分解 O(sqrt(N))
vector<pair<ll, ll>> prime_factorize(ll n) {
vector<pair<ll, ll>> ans;
for (ll i = 2; i*i <= n; i++) {
if (n % i != 0) continue;
ll e = 0;
while (n % i == 0) {
e++;
n /= i;
}
ans.push_back({i, e});
}
if (n != 1) ans.push_back({n, 1});
return ans;
}
// 各n以下の最小の素因数 O(NlogN)
vector<ll> smallest_prime(ll n) {
vector<ll> spf(n+1);
for (ll i = 0; i <= n; i++) spf[i] = i; //初期化
for (ll i = 2; i+i <= n; i++) {
if (spf[i] == i) {
for (ll j = i*i; j <= n; j += i) {
if (spf[j] == j) spf[j] = i;
}
}
}
return spf;
}
// 以下、コードを記すのである。
// using mint = modint998244353;
using mint = modint1000000007;
int main() {
int t; cin >> t;
while (t--) {
vector<vector<int>> pos(2, vector<int>(2));
vector<char> c(2);
for (int i = 0; i < 2; i++) {
cin >> pos[i][0] >> pos[i][1] >> c[i];
}
map<char, int> mp;
mp['U'] = 1;
mp['D'] = 1;
if (c[0] == c[1]) cout << no << endl;
else {
if (mp[c[0]] == mp[c[1]]) {
if (pos[0][1-mp[c[0]]] != pos[1][1-mp[c[1]]]) cout << no << endl;
else {
if (c[0] == 'R') {
if (pos[0][mp[c[0]]] < pos[1][mp[c[1]]]) cout << yes << endl;
else cout << no << endl;
}
if (c[0] == 'L') {
if (pos[0][mp[c[0]]] > pos[1][mp[c[1]]]) cout << yes << endl;
else cout << no << endl;
}
if (c[0] == 'U') {
if (pos[0][mp[c[0]]] < pos[1][mp[c[1]]]) cout << yes << endl;
else cout << no << endl;
}
if (c[0] == 'D') {
if (pos[0][mp[c[0]]] > pos[1][mp[c[1]]]) cout << yes << endl;
else cout << no << endl;
}
}
}
else {
if (pos[0][0] == pos[1][0] || pos[0][1] == pos[1][1]) cout << no << endl;
else {
int diffx = pos[1][0] - pos[0][0];
int diffy = pos[1][1] - pos[0][1];
if (abs(diffx) != abs(diffy)) cout << no << endl;
else {
if (c[0] == 'R' && diffx > 0) {
if ((diffy > 0 && c[1] == 'D') || (diffy < 0 && c[1] == 'U')) {
cout << yes << endl;
}
}
else if (c[0] == 'L' && diffx < 0) {
if ((diffy > 0 && c[1] == 'D') || (diffy < 0 && c[1] == 'U')) {
cout << yes << endl;
}
}
else if (c[0] == 'U' && diffy > 0) {
if ((diffx > 0 && c[1] == 'L') || (diffx < 0 && c[1] == 'R')) {
cout << yes << endl;
}
}
else if (c[0] == 'D' && diffy < 0) {
if ((diffx > 0 && c[1] == 'L') || (diffx < 0 && c[1] == 'R')) {
cout << yes << endl;
}
}
else cout << no << endl;
}
}
}
}
}
}
lemon_math_tea