結果

問題 No.2632 Center of Three Points in Lp Norm
ユーザー maksimmaksim
提出日時 2024-02-16 22:58:28
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,621 bytes
コンパイル時間 1,579 ms
コンパイル使用メモリ 169,576 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-02-16 22:58:36
合計ジャッジ時間 6,687 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 58 ms
6,676 KB
testcase_01 WA -
testcase_02 AC 58 ms
6,676 KB
testcase_03 WA -
testcase_04 AC 58 ms
6,676 KB
testcase_05 AC 58 ms
6,676 KB
testcase_06 AC 58 ms
6,676 KB
testcase_07 AC 58 ms
6,676 KB
testcase_08 AC 58 ms
6,676 KB
testcase_09 AC 58 ms
6,676 KB
testcase_10 AC 58 ms
6,676 KB
testcase_11 WA -
testcase_12 AC 58 ms
6,676 KB
testcase_13 AC 58 ms
6,676 KB
testcase_14 AC 58 ms
6,676 KB
testcase_15 AC 58 ms
6,676 KB
testcase_16 AC 58 ms
6,676 KB
testcase_17 AC 58 ms
6,676 KB
testcase_18 AC 58 ms
6,676 KB
testcase_19 AC 58 ms
6,676 KB
testcase_20 AC 58 ms
6,676 KB
testcase_21 AC 59 ms
6,676 KB
testcase_22 WA -
testcase_23 AC 58 ms
6,676 KB
testcase_24 AC 58 ms
6,676 KB
testcase_25 AC 58 ms
6,676 KB
testcase_26 AC 58 ms
6,676 KB
testcase_27 AC 57 ms
6,676 KB
testcase_28 AC 58 ms
6,676 KB
testcase_29 AC 58 ms
6,676 KB
testcase_30 AC 59 ms
6,676 KB
testcase_31 AC 58 ms
6,676 KB
testcase_32 AC 58 ms
6,676 KB
testcase_33 AC 58 ms
6,676 KB
testcase_34 AC 7 ms
6,676 KB
testcase_35 AC 58 ms
6,676 KB
testcase_36 AC 58 ms
6,676 KB
testcase_37 AC 58 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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 second
pt 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;
}
0