結果

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

ソースコード

diff #
raw source code

#include<bits/stdc++.h>
#include<atcoder/all>
#define chmin(x,y) (x) = min((x),(y))
#define chmax(x,y) (x) = max((x),(y))
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define vec vector
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back 
#define eb emplace_back

using namespace std;
using namespace atcoder;
using ll = long long;
using ld = long double;
const ll mod = 998244353;
using mint = modint998244353;
const vector<int> dx = {1,0,-1,0}, dy = {0,1,0,-1};
// using Graph = vector<vector<pair<int,ll>>>;
using Graph = vector<vector<int>>;

int manh(int x1, int y1, int x2, int y2){
  return abs(x1-x2) + abs(y1-y2);
}

int main(){
  // input
  vec<int> X(3), Y(3);
  rep(i,3){
    cin >> X[i] >> Y[i];
    X[i] *= 4;
    Y[i] *= 4;
  }

  int L = -500 , R = 1000;

  // solve
  bool infinite = 0;
  vec<pair<double,double>> ans;
  for(int x = L; x <= R; x++){
    for(int y = L; y <= R; y++){
      set<int> st;
      rep(i,3) st.insert(manh(X[i],Y[i],x,y));

      if(st.size() == 1){
        ans.eb((double)x / 4.0,(double)y / 4.0);
        if(abs(x % 2) == 1 || abs(y % 2) == 1){
          infinite = 1;
          break;
        }
      }
    }
    if(infinite) break;
  }
  
  // output
  if(infinite) cout << -1 << endl;
  else{
    cout << ans.size() << "\n";
    for(auto[x,y] : ans)
      cout << x << " " << y << endl;
  }
}
0