結果

問題 No.2628 Shrinkage
ユーザー noya2
提出日時 2024-02-11 15:34:09
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 1,064 bytes
コンパイル時間 2,730 ms
コンパイル使用メモリ 246,940 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-09-28 19:38:37
合計ジャッジ時間 3,319 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 28
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using vec = pair<ll,ll>;

vec input_vec(){
    ll x, y; cin >> x >> y;
    return vec(x,y);
}

vec minus_vec(vec a, vec b){
    a.first -= b.first;
    a.second -= b.second;
    return a;
}

bool parallel_same_dir(vec a, vec b){
    ll cr = a.first * b.second - a.second * b.first;
    if (cr != 0) return false;
    ll dt = a.first * b.first + a.second * b.second;
    return dt > 0;
}

ll norm_vec(vec a){
    return a.first*a.first + a.second*a.second;
}

void solve(){
    vec p1 = input_vec();
    vec p2 = input_vec();
    vec q1 = input_vec();
    vec q2 = input_vec();
    vec p12 = minus_vec(p2,p1);
    vec q12 = minus_vec(q2,q1);
    if (!parallel_same_dir(p12,q12)){
        cout << "No" << endl;
    }
    else if (p12 == q12 && p1 == q1){
        cout << "Yes" << endl;
    }
    else if (norm_vec(p12) <= norm_vec(q12)){
        cout << "No" << endl;
    }
    else {
        cout << "Yes" << endl;
    }
}

int main(){
    int t; cin >> t;
    while (t--){
        solve();
    }
}
0