結果

問題 No.2564 衝突予測
ユーザー EtisEtis
提出日時 2023-12-02 16:37:05
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 10,448 bytes
コンパイル時間 6,897 ms
コンパイル使用メモリ 313,296 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-09-26 20:31:10
合計ジャッジ時間 8,500 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 57 ms
5,376 KB
testcase_04 AC 57 ms
5,376 KB
testcase_05 AC 57 ms
5,376 KB
testcase_06 AC 57 ms
5,376 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

//line 1 "main.cpp"
#if !__INCLUDE_LEVEL__
#define ETISING __FILE__
#include ETISING

#define AA Yes(1)

int main() {

    cincout::Etising();
    
    ll T;
    cin >> T;
    while(T--) {
        ll X1, Y1, X2, Y2;
        char D1, D2;
        cin >> X1 >> Y1 >> D1 >> X2 >> Y2 >> D2;

        if(D1 == 'U') {
            if(D2 == 'D') {
                if(X1 == X2 && Y1 < Y2) {
                    Yes(1);
                    continue;
                }
            }
            if(D2 == 'R') {
                ll X = X1, Y = Y2;
                if(X - X2 == Y - Y1) {
                    Yes(1);
                    continue;
                }
            }
            if(D2 == 'L') {
                ll X = X1, Y = Y2;
                if(X2 - X == Y - Y1) {
                    Yes(1);
                    continue;
                }
            }
        }
        if(D1 == 'D') {
            if(D2 == 'U') {
                if(X1 == X2 && Y1 > Y2) {
                    Yes(1);
                    continue;
                }
            }
            if(D2 == 'R') {
                ll X = X1, Y = Y2;
                if(X - X2 == Y1 - Y) {
                    Yes(1);
                    continue;
                }
            }
            if(D2 == 'L') {
                ll X = X1, Y = Y2;
                if(X2 - X == Y1 - Y) {
                    Yes(1);
                    continue;
                }
            }
        }
        if(D1 == 'R') {
            if(D2 == 'U') {
                ll X = X2, Y = Y1;
                if(X - X1 == Y - Y2) {
                    Yes(1);
                    continue;
                }
            }
            if(D2 == 'D') {
                ll X = X2, Y = Y1;
                if(X - X1 == Y2 - Y) {
                    Yes(1);
                    continue;
                }
            }
            if(D2 == 'L') {
                if(Y1 == Y2 && X1 < X2) {
                    Yes(1);
                    continue;
                }
            }
        }
        if(D1 == 'L') {
            if(D2 == 'U') {
                ll X = X2, Y = Y1;
                if(X1 - X == Y - Y2) {
                    Yes(1);
                    continue;
                }
            }
            if(D2 == 'D') {
                ll X = X2, Y = Y1;
                if(X1 - X == Y2 - Y) {
                    Yes(1);
                    continue;
                }
            }
            if(D2 == 'R') {
                if(Y1 == Y2 && X2 < X1) {
                    Yes(1);
                    continue;
                }
            }
        }

        Yes(0);
    }
}

#else
//line 1 "/home/etis/cpp-library/src/template.hpp"
#pragma GCC target("avx")
//#pragma GCC target("avx2")
#pragma GCC optimize("O3")
//#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#pragma GCC diagnostic ignored "-Wunused-parameter"
#pragma GCC diagnostic ignored "-Wsign-compare"
#pragma GCC diagnostic ignored "-Wdeprecated-copy"

#include <bits/stdc++.h>
using namespace std;

//local debug
#ifdef LOCAL
#include <debug_print.hpp>
#define debug(...) debug_print::multi_print(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (static_cast<void>(0))
#endif

//AtCoder Library
#if __has_include(<atcoder/all>)
#include <atcoder/all>
using mint = atcoder::modint998244353;
using Mint = atcoder::modint1000000007;
#endif

//alias
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using ld = long double;

//constants
constexpr const long long MOD = 998244353;
constexpr const long long MODM = 1000000007;
constexpr const int INF = 1e9;
constexpr const ll LINF = 1e18;
constexpr const ld PI = 3.1415926535;

//rep(for-loop) macro
#define overload4(a, b, c, d, e, ...) e
#define rep2(i, n) for(ll i = 0; i < n; i++)
#define rep3(i, k, n) for(ll i = k; i < n; i++)
#define rep4(i, k, n, a) for(ll i = k; i < n; i += a)
#define rep(...) overload4(__VA_ARGS__, rep4, rep3, rep2)(__VA_ARGS__)
#define rep1_2(i, n) for(ll i = 1; i <= n; i++)
#define rep1_3(i, k, n) for(ll i = k; i <= n; i++)
#define rep1_4(i, k, n, a) for(ll i = k; i <= n; i += a)
#define rep1(...) overload4(__VA_ARGS__, rep1_4, rep1_3, rep1_2)(__VA_ARGS__)
#define Rep2(i, n) for(ll i = n - 1; i >= 0; i--)
#define Rep3(i, k, n) for(ll i = n - 1; i >= k; i--)
#define Rep4(i, k, n, a) for(ll i = n - 1; i >= k; i -= a) 
#define Rep(...) overload4(__VA_ARGS__, Rep4, Rep3, Rep2)(__VA_ARGS__)
#define Rep1_2(i, n) for(ll i = n; i >= 1; i--)
#define Rep1_3(i, k, n) for(ll i = n; i >= k; i--)
#define Rep1_4(i, k, n, a) for(ll i = n; i >= k; i -= a) 
#define Rep1(...) overload4(__VA_ARGS__, Rep1_4, Rep1_3, Rep1_2)(__VA_ARGS__)
#define vfor(x, v) for(auto x : v)
#define mfor(map) for(auto &[key, value] : map)

//vector macro
#define vvecc(T, name, n, m) vector<vector<T>> name(n, vector<T>(m))
#define vvec(T, name, n) vector<vector<T>> name(n)
#define vvecs(T, name, n, m, s) vector<vector<T>> name(n, vector<T>(m, s))
#define vvvecc(T, name, n, m, h) vector<vector<vector<T>>> name(n, vector<vector<T>>(m, vector<T>(h)))
#define vvvecs(T, name, n, m, h, s) vector<vector<vector<T>>> name(n, vector<vector<T>>(m, vector<T>(h, s)))
#define LB(v, x) distance((v).begin(), lower_bound(all(v), (x)))
#define UB(v, x) distance((v).begin(), upper_bound(all(v), (x)))
#define MIN(v) *min_element(all(v))
#define MINI(v) distance(v.begin(), min_element(all(v)))
#define MAX(v) *max_element(all(v))
#define MAXI(v) distance(v.begin(), max_element(all(v)))
#define Sort(v) sort(all(v))
#define Rev(v) reverse(all(v))
template<class T> inline ll vsum(const vector<T> &v) {ll sum = 0; for(T x : v) sum += x; return sum;}

//iterator macro
#define all(v) begin(v), end(v)
#define rall(v) rbegin(v), rend(v)
#define rng(v, l, r) begin(v) + (l), begin(a) + (r)

//data structure macro
#define ef emplace_front
#define eb emplace_back
#define pf pop_front
#define pb pop_back
#define mp make_pair
#define fi first
#define se second
#define mt make_tuple
#define lb lower_bound
#define ub upper_bound
template<class T, class U> using um = unordered_map<T, U>;
template<class T> using pq = priority_queue<T>;
template<class T> using pqmin = priority_queue<T, vector<T>, greater<T>>;
template<class T, class U> using pqp = priority_queue<pair<T, U>>;
template<class T, class U> using pqpmin = priority_queue<pair<T, U>, vector<pair<T, U>>, greater<pair<T,U>>>;

//output
#define pl() cout << '\n'
#define ifl(i, k) " \n"[i == k]
template<class T> inline void print(const T& a) {cout << a;}
inline void printl() {}
template<class T> inline void printl(const T& t) {print(t); pl();}
template<class T> inline void printf(const T& t) {print(t); pl(); cout << flush;}
template<class Head, class... Tail> inline void printl(const Head& head, const Tail&... tail) {print(head); cout << " "; printl(tail...);}
template<class Head, class... Tail> inline void printf(const Head& head, const Tail&... tail) {print(head); cout << " "; printl(tail...); cout << flush;}
template<class T> inline void printl(const vector<T>& v) {if(v.size() == 0) return; print(v[0]); for(auto i = v.begin(); ++i != v.end();) {cout << " "; print(*i);}}
template<class T> inline void printl1(const vector<T>& v) {if(v.size() <= 1) return; print(v[1]); for(auto i = v.begin() + 1; ++i != v.end();) {cout << " "; print(*i);}}
template<class T> inline void prints(const T& a) {cout << a << " ";}
template<class T> inline void fin(const T& t) {printl(t); exit(0);}
inline void Yes(bool a) {cout << (a ? "Yes" : "No") << '\n';}
template<class T, class U> inline void Out2(bool a, T yes, U no) {if(a) printl(yes); else printl(no);}

//functions
inline int ctoi(char c) {return c - '0';}
inline char to_char(int x) {return x + '0';}
inline bool bw(ll a, ll x, ll b) {return (a < x && x < b);}
inline bool bwe(ll a, ll x, ll b) {return (a <= x && x <= b);}
template<class... T> inline constexpr auto Emin(T... a) {return min(initializer_list<common_type_t<T...>>{a...});}
template<class... T> inline constexpr auto Emax(T... a) {return max(initializer_list<common_type_t<T...>>{a...});}
template<class T, class U> inline bool chmax(T &a, const U &b) {if (a < b) { a = b; return true;} return false;}
template<class T, class U> inline bool chmin(T &a, const U &b) {if (a > b) { a = b; return true;} return false;}
template<class T, class U> inline ll Epow(T x, U y) {ll ans = 1; for(int i = 0; i < y; i++) ans *= x; return ans;}
template<class T, class U> inline ll Eceil(T x, U y) {return (ll)ceil((ld)x / (ld)y);}
template<class T, class U> inline ll Efloor(T x, U y) {return (ll)floor((ld)x / (ld)y);}
template<class T, class U> inline bool check_bit(T tar, U bit) {return ((tar & Epow(2, bit)) != 0);}
template<class T> inline bool overflow_if_add(T a, T b) {return (std::numeric_limits<T>::max() - a) < b;}
template<class T> inline bool overflow_if_mul(T a, T b) {return (std::numeric_limits<T>::max() / a) < b;}

//pair-sort
template<class T, class U> inline bool pud(pair<T, U>& left, pair<T, U>& right) {
    if (left.first == right.first) return right.second < left.second;
    else return left.first  < right.first;
}
template<class T, class U> inline bool pdu(pair<T, U>& left, pair<T, U>& right) {
    if (left.first == right.first) return left.second < right.second;
    else return right.first < left.first;
}

namespace cincout {
    void Etising() {
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
        cout << fixed << setprecision(15);
    }
}

struct exec_time {
    private:
        std::chrono::system_clock::time_point start, end;
    public:
        exec_time() : start(std::chrono::system_clock::now()) {}
        ll get_time() {
            end = std::chrono::system_clock::now();
            ll ret = (ll)std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count();
            return ret;
        }
};

void cordp(vector<ll> &A) {
    vector<ll> sorted;
    map<ll, vector<int>> idx;
    rep(i, A.size()) {
        sorted.eb(A[i]);
        idx[A[i]].eb(i);
    }
    Sort(sorted);
    sorted.erase(unique(all(sorted)), sorted.end());
    rep(i, sorted.size()) vfor(x, idx[sorted[i]]) A[x] = i;
}

vector<vector<char>> roll(const vector<vector<char>> &A, int H, int W) {
    vector<vector<char>> ret(W, vector<char>(H));
    rep(i, H) rep(j, W) ret[j][H - i - 1] = A[i][j];
    return ret;
}
//line 113 "main.cpp"
#endif
0