結果

問題 No.2632 Center of Three Points in Lp Norm
ユーザー maksim
提出日時 2024-02-16 22:37:12
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,293 bytes
コンパイル時間 1,475 ms
コンパイル使用メモリ 170,400 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-09-28 21:12:27
合計ジャッジ時間 4,928 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 WA * 2
other AC * 10 WA * 24
権限があれば一括ダウンロードができます

ソースコード

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