結果

問題 No.2628 Shrinkage
コンテスト
ユーザー こめだわら
提出日時 2026-07-29 20:06:42
言語 C++23
(gcc 15.2.0 + boost 1.90.0)
コンパイル:
g++-15 -O2 -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 1 ms / 2,000 ms
+ 410µs
コード長 2,550 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,960 ms
コンパイル使用メモリ 332,648 KB
実行使用メモリ 5,888 KB
最終ジャッジ日時 2026-07-29 20:06:47
合計ジャッジ時間 3,322 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 28
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;

#define rep(i,n) for(ll i=0;i<n;++i)
#define all(a) (a).begin(),(a).end()
ll intpow(ll a, ll b){ ll ans = 1; while(b){ if(b & 1) ans *= a; a *= a; b /= 2; } return ans; }
ll modpow(ll a, ll b, ll p){ ll ans = 1; while(b){ if(b & 1) (ans *= a) %= p; (a *= a) %= p; b /= 2; } return ans; }
template<class T> T div_floor(T a, T b) { return a / b - ((a ^ b) < 0 && a % b); }
template<class T> T div_ceil(T a, T b) { return a / b + ((a ^ b) > 0 && a % b); }
template <typename T, typename U> inline bool chmin(T &x, U y) { return (y < x) ? (x = y, true) : false; }
template <typename T, typename U> inline bool chmax(T &x, U y) { return (x < y) ? (x = y, true) : false; }

template<typename T>
ostream &operator<<(ostream &os, const vector<T> &a){
    if (a.empty()) return os;
    os << a.front();
    for (auto e : a | views::drop(1)){
        os << ' ' << e;
    }
    return os;
}

void dump(auto ...vs){
    ((cout << vs << ' '), ...) << endl;
}

pair<ll,ll> operator+(pair<ll,ll> a,pair<ll,ll> b){
    return {a.first+b.first,a.second+b.second};
}
pair<ll,ll> operator-(pair<ll,ll> a,pair<ll,ll> b){
    return {a.first-b.first,a.second-b.second};
}

ll cross(pair<ll,ll> a,pair<ll,ll> b){
    return a.first*b.second-a.second*b.first;
}

ll dot(pair<ll,ll> a,pair<ll,ll> b){
    return a.first*b.first+a.second*b.second;
}

ll len2(pair<ll,ll> a){
    return a.first*a.first+a.second*a.second;
}

bool operator==(pair<ll,ll> a,pair<ll,ll> b){
    return (a.first==b.first)&&(a.second==b.second); 
}

void solve() {
    pair<ll,ll> p1,p2,q1,q2;
    auto input=[](pair<ll,ll> &a){
        cin>>a.first>>a.second;
    };
    input(p1);
    input(p2);
    input(q1);
    input(q2);
    if(q1==p1 and q2==p2){
        cout<<"Yes"<<'\n';
        return;
    }
    pair<ll,ll> pv=p2-p1;
    pair<ll,ll> qv=q2-q1;
    if (len2(pv)==0){
        if (len2(qv)==0){
            cout<<"Yes"<<'\n';
            return;
        }
        else{
            cout<<"No"<<'\n';
            return;
        }
    }
    if (len2(qv)==0){
        cout<<"No"<<'\n';
        return;
    }
    if (len2(pv)<=len2(qv)){
        cout<<"No"<<'\n';
        return;
    }
    if (cross(pv,qv)!=0){
        cout<<"No"<<'\n';
        return;
    }
    if (dot(pv,qv)>=0){
        cout<<"Yes"<<'\n';
    }
    else{
        cout<<"No"<<'\n';
    }
    return;
}


int main() {
    ll T=1;
    cin>>T;
    while (T--){
        solve();
    }
    return 0;
}
0