結果
問題 | No.2632 Center of Three Points in Lp Norm |
ユーザー |
|
提出日時 | 2024-02-16 22:58:28 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,621 bytes |
コンパイル時間 | 1,762 ms |
コンパイル使用メモリ | 169,912 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-09-28 21:34:25 |
合計ジャッジ時間 | 6,430 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 30 WA * 4 |
ソースコード
#include <bits/stdc++.h>using namespace std;#define int long long#define app push_back#define all(x) (x).begin(),(x).end()#ifdef LOCAL#define debug(...) [](auto...a){ ((cout << a << ' '), ...) << endl;}(#__VA_ARGS__, ":", __VA_ARGS__)#else#define debug(...)#endif#ifdef LOCAL#define __int128 long long#endif // LOCAL#define double long double#define pt pair<double,double>#define x first#define y secondpt operator*(double c,pt a) {return pt(c*a.x,c*a.y);}pt operator-(pt a,pt b) {return pt(a.x-b.x,a.y-b.y);}pt operator+(pt a,pt b) {return pt(a.x+b.x,a.y+b.y);}double p;double dist(pt a,pt b){return pow(abs(a.x-b.x),p)+pow(abs(a.y-b.y),p);}pt a[3];double f2(pt u){return abs(dist(u,a[0])-dist(u,a[1]));}double f(double x){double low=(-1e7);double up=1e7;for(int it=0;it<100;++it){double yl=(2*low+up)/3;double yr=(low+2*up)/3;if(f2(pt(x,yl))<f2(pt(x,yr))) {up=yr;} else {low=yl;}}return (low+up)/2.0;}double g(pt u){return abs(dist(u,a[0])-dist(u,a[2]));}int32_t main(){ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);cin>>p;for(int i=0;i<3;++i) cin>>a[i].x>>a[i].y;double low=(-1e9);double up=1e9;for(int it=0;it<100;++it){double xl=(2*low+up)/3;double xr=(low+2*up)/3;double yl=f(xl);double yr=f(xr);debug(xl,yl);debug(xr,yr);double gl=g({xl,yl});double gr=g({xr,yr});debug(g(pt(xl,yl)));if(gl<gr) {up=xr;} else {low=xl;}}double x=(low+up)/2.0;double y=f(x);cout<<fixed<<setprecision(25)<<x<<' '<<y;return 0;}