結果

問題 No.168 ものさし
ユーザー codershifthcodershifth
提出日時 2015-12-29 15:07:19
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,577 bytes
コンパイル時間 1,678 ms
コンパイル使用メモリ 170,116 KB
実行使用メモリ 11,000 KB
最終ジャッジ日時 2023-10-19 12:20:32
合計ジャッジ時間 3,535 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 WA -
testcase_06 AC 1 ms
4,348 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 3 ms
4,348 KB
testcase_10 AC 6 ms
4,348 KB
testcase_11 AC 45 ms
4,664 KB
testcase_12 AC 85 ms
8,624 KB
testcase_13 AC 139 ms
11,000 KB
testcase_14 AC 26 ms
11,000 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,a,b) for(int (i)=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define RANGE(vec) (vec).begin(),(vec).end()

using namespace std;

class Ruler {
public:
    void solve(void) {
        int N;
        cin>>N;

        vector<ll> xs(N);
        vector<ll> ys(N);
        REP(i,N)
        {
            cin>>xs[i]>>ys[i];
        }

        vector<vector<double>> dist(N,vector<double>(N,0));
        REP(i,N)
        REP(j,i+1)
        {
            dist[i][j] = dist[j][i] = hypot(xs[i]-xs[j], ys[i]-ys[j]);
        }
        double low = 0;
        double high = dist[0][N-1]+1;
        vector<bool> vis(N,false);
        for (int i = 0; i < 200; ++i)
        {
            double mid = (low+high)/2;

            if ( abs(low-high) < 1e-6 )
                break;

            fill(RANGE(vis),false);
            function<void(int)> dfs = [&](int v) {
                vis[v] = true;
                REP(u,N)
                {
                    if (vis[u])
                        continue;
                    if (dist[v][u] > mid)
                        continue;
                    dfs(u);
                }
            };
            dfs(0);
            if (vis[N-1])
                high = mid;
            else
                low = mid;
        }
        cout<<ceil(low/10.0)*10<<endl;
    }
};

#if 1
int main(int argc, char *argv[])
{
        ios::sync_with_stdio(false);
        auto obj = new Ruler();
        obj->solve();
        delete obj;
        return 0;
}
#endif
0