結果

問題 No.55 正方形を描くだけの簡単なお仕事です。
コンテスト
ユーザー C
提出日時 2026-09-24 02:43:50
言語 C++23(gcc16)
(gcc 16.1.0 + boost 1.92.0 + ACL)
コンパイル:
g++-16 -O2 -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 1 ms / 5,000 ms
+ 261µs
コード長 1,493 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 7,316 ms
コンパイル使用メモリ 393,668 KB
実行使用メモリ 7,852 KB
最終ジャッジ日時 2026-09-24 02:44:06
合計ジャッジ時間 8,562 ms
ジャッジサーバーID
(参考情報)
judge4_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
#include <atcoder/all>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace atcoder;
using namespace __gnu_pbds;
using ll=long long;
using ld=long double;
using vll=vector<ll>;
using vvll=vector<vll>;
using pll=pair<ll,ll>;

// using mint=modint;

// template<class K,class V>
// using ordered_map=tree<K,V,less<K>,rb_tree_tag,tree_order_statistics_node_update>;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

    ll X1,Y1,X2,Y2,X3,Y3;
    cin>>X1>>Y1>>X2>>Y2>>X3>>Y3;

    vector<pll> p={{X1,Y1},{X2,Y2},{X3,Y3}};

    //直角の頂点をp[i]と仮定する
    for(int i=0;i<3;++i){
        //直角の頂点をp[i]とし
        ll j=(i+1)%3,k=(i+2)%3;
        //まず、p[i]を原点に移動する
        ll a=p[j].first-p[i].first;
        ll c=p[k].first-p[i].first;
        ll b=p[j].second-p[i].second;
        ll d=p[k].second-p[i].second;
        //今は(a,b)(0,0)(c,d)
        //(1)00 -> ab は 00 -> cd と垂直のはず
        //(2)00 -> ab と 00 -> cd の距離は同値のはず
        //内積の式を使います
        if(a*c+b*d==0&&a*a+b*b==c*c+d*d){
            //ベクトル加算の式
            //p[i]を元に戻すとめ+p[i].firstと+p[i].secondが必要です(本来は(0,0)ではないため)
            cout<<a+c+p[i].first<<" "<<b+d+p[i].second<<endl;
            return 0;
        }
    }
    cout<<-1<<endl;
}
0