結果

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

テストケース

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

ソースコード

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 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 f(pt a,pt b,double len)
{
    double l1=dist(a,b);
    return a+pow(len/l1,1/p)*(b-a);
}
int32_t main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    cin>>p;
    pair<double,double> a[3];for(int i=0;i<3;++i) cin>>a[i].first>>a[i].second;
    pair<double,double> cur=a[0];
    double cudi=max({dist(a[0],a[1]),dist(a[1],a[2]),dist(a[2],a[0])});
    debug(cudi);
    for(int it=0;it<100000;++it)
    {
        cudi*=0.999;
        double d[3];for(int i=0;i<3;++i) {d[i]=dist(cur,a[i]);}
        int pos=max_element(d,d+3)-d;
        cur=f(cur,a[pos],cudi);
    }
    cout<<setprecision(25)<<cur.x<<' '<<cur.y;
    return 0;
}
0