結果
| 問題 | No.3664 Manhattan Circumcenter |
| コンテスト | |
| ユーザー |
Kude
|
| 提出日時 | 2026-08-30 16:23:32 |
| 言語 | C++23 (gcc 15.3.0 + boost 1.92.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 6,908 bytes |
| 記録 | |
| コンパイル時間 | 2,908 ms |
| コンパイル使用メモリ | 364,520 KB |
| 実行使用メモリ | 6,400 KB |
| 最終ジャッジ日時 | 2026-08-30 16:23:40 |
| 合計ジャッジ時間 | 6,646 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 WA * 1 |
| other | AC * 17 WA * 22 RE * 18 |
ソースコード
#include<bits/stdc++.h>
namespace {
#pragma GCC diagnostic ignored "-Wunused-function"
#include<atcoder/all>
#pragma GCC diagnostic warning "-Wunused-function"
using namespace std;
using namespace atcoder;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(i,n) for(int i = (int)(n) - 1; i >= 0; i--)
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
template<class T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }
template<class T> bool chmin(T& a, const T& b) { if (b < a) { a = b; return true; } else return false; }
using ll = long long;
using P = pair<int,int>;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;
struct Vec {
using etype = long long; // type of elements
using ptype = long long; // type of product results
etype x = 0, y = 0;
constexpr Vec operator-() const { return {-x, -y}; }
friend constexpr Vec operator+(const Vec& a, const Vec& b) { return {a.x + b.x, a.y + b.y}; }
friend constexpr Vec operator-(const Vec& a, const Vec& b) { return {a.x - b.x, a.y - b.y}; }
friend constexpr ptype operator*(const Vec& a, const Vec& b) { return (ptype)a.x * b.y - (ptype)a.y * b.x; }
template <class T, enable_if_t<is_integral_v<T>>* = nullptr>
friend constexpr Vec operator*(T c, const Vec& a) { return {c * a.x, c * a.y}; }
template <class T, enable_if_t<is_integral_v<T>>* = nullptr>
friend constexpr Vec operator*(const Vec& a, T c) { return c * a; }
template <class T, enable_if_t<is_integral_v<T>>* = nullptr>
friend constexpr Vec operator/(const Vec& a, T c) { return {a.x / c, a.y / c}; }
Vec& operator+=(const Vec& a) { x += a.x; y += a.y; return *this; }
Vec& operator-=(const Vec& a) { x -= a.x; y -= a.y; return *this; }
template <class T, enable_if_t<is_integral_v<T>>* = nullptr>
Vec& operator*=(T c) { x *= c; y *= c; return *this; }
friend constexpr bool operator==(const Vec& a, const Vec& b) { return a.x == b.x && a.y == b.y; }
friend constexpr bool operator!=(const Vec& a, const Vec& b) { return !(a == b); }
constexpr int quadrant() const { return y > 0 ? (x > 0 ? 0 : 1) : y < 0 ? (x < 0 ? 2 : 3) : (x > 0 ? 0 : x < 0 ? 2 : -1); }
friend constexpr bool operator<(const Vec& a, const Vec& b) {
int qa = a.quadrant(), qb = b.quadrant();
if (qa != qb) return qa < qb;
ptype p1 = (ptype)a.x * b.y, l2 = (ptype)a.y * b.x;
return p1 > l2 || (p1 == l2 && (a.x != 0 ? abs(a.x) < abs(b.x) : abs(a.y) < abs(b.y)));
}
friend constexpr bool operator>(const Vec& a, const Vec& b) { return b < a; }
friend constexpr bool operator<=(const Vec& a, const Vec& b) { return !(b < a); }
friend constexpr bool operator>=(const Vec& a, const Vec& b) { return !(a < b); }
constexpr int ccw(const Vec& u, const Vec& v) const { ptype p = (u - *this) * (v - *this); return p > 0 ? 1 : p < 0 ? -1 : 0; }
static constexpr bool intersects(const Vec& a, const Vec& b, const Vec& c, const Vec& d) { return a.ccw(b, c) * a.ccw(b, d) <= 0 && c.ccw(d, a) * c.ccw(d, b) <= 0; }
constexpr bool parallel_to(const Vec& a) const { return (ptype)x * a.y == (ptype)y * a.x; }
constexpr ptype dot(const Vec& a) const { return (ptype)x * a.x + (ptype)y * a.y; }
constexpr ptype norm2() const { return (ptype)x * x + (ptype)y * y; }
constexpr bool is_zero() const { return x == 0 && y == 0; }
constexpr Vec normalize() const {
if (x == 0) return Vec{0, (y == 0 ? 0 : 1)};
etype g = gcd(x, y);
return *this / (x > 0 ? g : -g);
}
constexpr Vec rot90() const { return {-y, x}; }
// exclusive
constexpr bool in_between(const Vec& a, const Vec& b) const {
Vec x = a - *this, y = b - *this;
return x.parallel_to(y) && x.dot(y) < 0;
}
friend std::ostream& operator<< (std::ostream& os, const Vec& t) { return os << t.x << ' ' << t.y; }
friend std::istream& operator>> (std::istream& os, Vec& t) { return os >> t.x >> t.y; }
};
} int main() {
ios::sync_with_stdio(false);
cin.tie(0);
Vec a, b, c;
cin >> a >> b >> c;
a *= 4;
b *= 4;
c *= 4;
if (a == b || b == c || c == a) {
cout << -1 << '\n';
return 0;
}
constexpr int INF = 1001001001;
auto f = [&](Vec a, Vec b, Vec c) {
bool xflip = a.x > b.x;
bool yflip = a.y > b.y;
if (xflip) a.x *= -1, b.x *= -1, c.x *= -1;
if (yflip) a.y *= -1, b.y *= -1, c.y *= -1;
int dx = b.x - a.x, dy = b.y - a.y;
bool dflip = dx > dy;
if (dflip) swap(dx, dy), swap(a.x, a.y), swap(b.x, b.y), swap(c.x, c.y);
int d = (dx + dy) / 2;
Vec u = {a.x, a.y + d}, v = {b.x, b.y - d};
vector<pair<Vec, Vec>> res;
res.emplace_back(u, v);
res.emplace_back(Vec{-INF, u.y}, u);
res.emplace_back(Vec{INF, v.y}, v);
if (dx == dy) {
if (!(a.x < c.x && c.x < b.x && a.y < c.y && c.y < b.y)) {
cout << -1 << '\n';
exit(0);
}
}
if (dflip) for (auto& [x, y] : res) swap(x, y);
if (yflip) for (auto& [x, y] : res) y *= -1;
if (xflip) for (auto& [x, y] : res) x *= -1;
return res;
};
auto s1 = f(a, b, c);
auto s2 = f(a, c, b);
vector<Vec> ans;
rep(i, ssize(s1)) rep(j, ssize(s2)) {
auto [u1,v1] = s1[i];
auto [u2,v2] = s2[j];
auto d1 = u1 - v1;
auto d2 = u2 - v2;
if (d1 * d2 == 0) {
if (d1 == Vec{0, 0}) swap(d1, d2);
if (d1 == Vec{0, 0}) {
if (u1 == u2) ans.emplace_back(u1);
continue;
}
auto h = d1.rot90();
if (u1 * h != u2 * h) continue;
ll l1 = d1 * u1, r1 = d1 * v1;
ll l2 = d1 * u2, r2 = d1 * v2;
if (l1 > r1) swap(l1, r1);
if (l2 > r2) swap(l2, r2);
if (l1 < r2 && l2 < r1) {
cout << -1 << '\n';
return 0;
}
rep(_, 2) {
rep(_, 2) {
if (u1 == u2) ans.emplace_back(u1);
swap(u2, v2);
}
swap(u1, v1);
}
} else {
ll x1 = u1.y * 1 - 1 * v1.y;
ll y1 = 1 * v1.x - u1.x * 1;
ll z1 = u1.x * v1.y - u1.y * v1.x;
ll g = gcd(gcd(x1, y1), z1);
x1 /= g, y1 /= g, z1 /= g;
ll x2 = u2.y * 1 - 1 * v2.y;
ll y2 = 1 * v2.x - u2.x * 1;
ll z2 = u2.x * v2.y - u2.y * v2.x;
g = gcd(gcd(x2, y2), z2);
x2 /= g, y2 /= g, z2 /= g;
ll x = y1 * z2 - z1 * y2;
ll y = z1 * x2 - x1 * z2;
ll z = x1 * y2 - y1 * x2;
g = gcd(gcd(x, y), z);
x /= g;
y /= g;
z /= g;
if (z < 0) x *= -1, y *= -1, z *= -1;
assert(z == 1);
Vec p{x, y};
bool ok = true;
rep(_, 2) {
ll l = u1 * d1, r = u2 * d1;
if (l > r) swap(l, r);
ll t = p * d1;
ok &= l <= t && t <= r;
swap(u1, u2);
swap(v1, v2);
}
if (ok) ans.emplace_back(p);
}
}
sort(all(ans));
ans.erase(unique(all(ans)), ans.end());
cout << ans.size() << '\n';
for (auto [x, y] : ans) {
cout << x / 4.0 << ' ' << y / 4.0 << '\n';
}
}
Kude