結果

問題 No.3664 Manhattan Circumcenter
コンテスト
ユーザー GOTKAKO
提出日時 2026-08-30 15:47:09
言語 C++17
(gcc 15.3.0 + boost 1.92.0)
コンパイル:
g++-15 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 163 ms / 2,000 ms
+ 15µs
コード長 1,598 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,181 ms
コンパイル使用メモリ 215,960 KB
実行使用メモリ 6,400 KB
最終ジャッジ日時 2026-08-30 15:47:23
合計ジャッジ時間 9,485 ms
ジャッジサーバーID
(参考情報)
judge3_1 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 57
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
 
    pair<int,int> P,Q,R;
    cin >> P.first >> P.second,P.first *= 2,P.second *= 2;
    cin >> Q.first >> Q.second,Q.first *= 2,Q.second *= 2;
    cin >> R.first >> R.second,R.first *= 2,R.second *= 2;
 
    auto dist = [&](int x1,int y1,int x2,int y2) -> int {return abs(x1-x2)+abs(y1-y2);};

    vector<pair<int,int>> answer,answer2;
    for(int i=-2000; i<=2000; i++) for(int k=-2000; k<=2000; k++){
        auto [x1,y1] = P;
        auto [x2,y2] = Q;
        auto [x3,y3] = R;
        int d1 = dist(x1,y1,i,k);
        int d2 = dist(x2,y2,i,k);
        int d3 = dist(x3,y3,i,k);
        if(d1 == d2 && d2 == d3){
            if(max(abs(i),abs(k)) > 1000){cout << "-1\n"; return 0;}
            answer.push_back({i,k});
        }    
    }
    P.first *= 2,P.second *= 2;
    Q.first *= 2,Q.second *= 2;
    R.first *= 2,R.second *= 2;
    for(int i=-4000; i<=4000; i++) for(int k=-4000; k<=4000; k++){
        auto [x1,y1] = P;
        auto [x2,y2] = Q;
        auto [x3,y3] = R;
        int d1 = dist(x1,y1,i,k);
        int d2 = dist(x2,y2,i,k);
        int d3 = dist(x3,y3,i,k);
        if(d1 == d2 && d2 == d3){
            if(max(abs(i),abs(k)) > 2000){cout << "-1\n"; return 0;}
            answer2.push_back({i,k});
        }    
    }
    if(answer.size() != answer2.size()){cout << "-1\n"; return 0;}
    cout << answer.size() << "\n";
    cout << fixed << setprecision(20);
    for(auto [x,y] : answer){
        cout << x/2.0 << " " << y/2.0 << "\n";
    }
    
}
0