結果

問題 No.456 Millions of Submits!
ユーザー kimiyukikimiyuki
提出日時 2016-12-08 13:15:00
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,998 bytes
コンパイル時間 2,439 ms
コンパイル使用メモリ 102,544 KB
実行使用メモリ 33,228 KB
最終ジャッジ日時 2023-09-05 14:24:49
合計ジャッジ時間 5,418 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 WA -
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <vector>
#include <algorithm>
#include <array>
#include <set>
#include <map>
#include <queue>
#include <tuple>
#include <unordered_set>
#include <iostream>
#include <unordered_map>
#include <functional>
#include <cmath>
#include <cassert>
#define repeat(i,n) for (int i = 0; (i) < int(n); ++(i))
#define repeat_from(i,m,n) for (int i = (m); (i) < int(n); ++(i))
#define repeat_reverse(i,n) for (int i = (n)-1; (i) >= 0; --(i))
#define repeat_from_reverse(i,m,n) for (int i = (n)-1; (i) >= int(m); --(i))
#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
using namespace std;
const double eps = 1e-10;
double binsearch(int a, int b, double t, double l, double r) {
    auto f = [&](double n) {
        return pow(n, a) * pow(log(n), b);
    };
    int iteration = max<int>(10, log(r - l) * 10);
    while (iteration --) {
        double m = (l + r) / 2;
        (f(m) < t ? l : r) = m;
    }
    return l;
}
int main() {
    // input
    int m; scanf("%d", &m);
    vector<int> as(m), bs(m);
    vector<double> ts(m);
    repeat (i,m) scanf("%d%d%lf", &as[i], &bs[i], &ts[i]);
    // solve
    array<array<vector<int>, 10+1>, 10+1> xs = {};
    repeat (i,m) xs[as[i]][bs[i]].push_back(i);
    vector<double> n(m);
    repeat (a,10+1) {
        repeat (b,10+1) {
            if (b == 0) {
                for (int x : xs[a][b]) {
                    n[x] = pow(ts[x], 1.0/a);
                }
            } else {
                whole(sort, xs[a][b], [&](int x, int y) {
                    return ts[x] < ts[y];
                });
                double r = 22027; // exp(10)
                repeat_reverse (i, int(xs[a][b].size())) {
                    int x = xs[a][b][i];
                    double t = ts[x];
                    r = n[x] = binsearch(a, b, t, 1, r);
                }
            }
        }
    }
    // output
    repeat (i,m) {
        printf("%.12lf\n", n[i]);
    }
    return 0;
}
0