QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#660918#2139. The Math of SailingSorahISA#AC ✓0ms4044kbC++2311.2kb2024-10-20 13:56:122024-10-20 13:56:12

Judging History

This is the latest submission verdict.

  • [2024-10-20 13:56:12]
  • Judged
  • Verdict: AC
  • Time: 0ms
  • Memory: 4044kb
  • [2024-10-20 13:56:12]
  • Submitted

answer

#ifndef SorahISA
#define SorahISA
#include SorahISA __FILE__ SorahISA

const double eps = 1e-9;

void solve() {
    vector<int> T(4);
    for (int &x : T) cin >> x;
    
    double ans = 0.0;
    vector<int> ans_perm{0, 1, 2, 3};
    vector<double> ans_T{1.0, 1.0, 1.0, 1.0};
    
    vector<int> perm{0, 1, 2, 3};
    do {
        double a = T[perm[0]], b = T[perm[1]], c = T[perm[2]], d = T[perm[3]];
        if (T[perm[3]] == 1 or (a-1) * (d-1) < (b-1) * (c-1)) continue;
        a = (b-1) * (c-1) / (d-1) + 1;
        if (a > T[perm[0]] + eps) continue;
        double val = a * d + b + c;
        if (chmax(ans, val)) ans_perm = perm, ans_T = {a, b, c, d};
        // debug(a, b, c, d, a * d + b + c, a + d + b * c);
    } while (next_permutation(ALL(perm)));
    
    for (int i = 0; i < 4; ++i) cout << ans_perm[i] + 1 << " \n"[i+1 == 4];
    for (int i = 0; i < 4; ++i) cout << fixed << setprecision(15) << ans_T[i] << " \n"[i+1 == 4];
    
    for (int i = 0; i < 4; ++i) assert(ans_T[i] <= T[ans_perm[i]] + eps);
}

int32_t main() {
    fastIO();
    
    int t = 1; // cin >> t;
    for (int _ = 1; _ <= t; ++_) {
        // cout << "Case #" << _ << ": ";
        solve();
    }
    
    return 0;
}

#else

#ifdef local
#define _GLIBCXX_DEBUG 1
#endif
#pragma GCC optimize("Ofast", "unroll-loops")
#include <bits/stdc++.h>
using namespace std;
// #include <bits/extc++.h>
// #include <tr2/dynamic_bitset>

using i64 = long long;
using i128 = __int128;
#define int i64
using f80 = long double;
using f128 = __float128;
#define double f80
using pii = pair<int, int>;
template <typename T> using Prior = std::priority_queue<T>;
template <typename T> using prior = std::priority_queue<T, vector<T>, greater<T>>;

// #define X first
// #define Y second
#define eb emplace_back
#define ef emplace_front
#define ee emplace
#define pb pop_back
#define pf pop_front
#define ALL(x) begin(x), end(x)
#define RALL(x) rbegin(x), rend(x)
#define SZ(x) ((int)(x).size())

// template <size_t D, typename T> struct Vec : vector<Vec<D-1, T>> {
//     static_assert(D >= 1, "Vector dimension must be greater than zero!");
//     template <typename... Args> Vec(int n = 0, Args... args) : vector<Vec<D-1, T>>(n, Vec<D-1, T>(args...)) {}
// };

// template <typename T> struct Vec<1, T> : vector<T> {
//     Vec(int n = 0, const T& val = T()) : vector<T>(n, val) {}
// };

#ifdef local
#define fastIO() void()
#define debug(...) \
    _color.emplace_back("\u001b[31m"), \
    fprintf(stderr, "%sAt [%s], line %d: (%s) = ", _color.back().c_str(), __FUNCTION__, __LINE__, #__VA_ARGS__), \
    _do(__VA_ARGS__), _color.pop_back(), \
    fprintf(stderr, "%s", _color.back().c_str())
#define print(...) \
    fprintf(stdout, "%s", "\u001b[36m"), \
    _P(__VA_ARGS__), \
    fprintf(stdout, "%s", "\u001b[0m")

deque<string> _color{"\u001b[0m"};

template <typename T> concept is_string = is_same_v<T, string&> or is_same_v<T, const string&>;
template <typename T> concept is_iterable = requires (T _t) { begin(_t); };

template <typename T> inline void _print_err(T &&_t);
template <typename T> inline void _print_err(T &&_t) requires is_iterable<T> and (not is_string<T>);
template <size_t I, typename ...U> inline typename enable_if<I == sizeof...(U), void>::type _print_err(const tuple<U...> &);
template <size_t I, typename ...U> inline typename enable_if<I <  sizeof...(U), void>::type _print_err(const tuple<U...> &_t);
template <size_t I, typename ...U> inline typename enable_if<I == sizeof...(U), void>::type _print_err(tuple<U...> &);
template <size_t I, typename ...U> inline typename enable_if<I <  sizeof...(U), void>::type _print_err(tuple<U...> &_t);
template <typename T, typename U> ostream& operator << (ostream &os, const pair<T, U> &_tu);

inline void _do() { cerr << "\n"; }
template <typename T> inline void _do(T &&_t) { _print_err(_t), cerr << "\n"; }
template <typename T, typename ...U> inline void _do(T &&_t, U &&..._u) { _print_err(_t), cerr << ", ", _do(_u...); }
#else
#define fastIO() cin.tie(0)->sync_with_stdio(0)
#define debug(...) void()
#define print(...) _P(__VA_ARGS__)
#endif

inline void _P() { cout << "\n"; }
template <typename T> inline void _P(T &&_t) { cout << _t << "\n"; }
template <typename T, typename ...U> inline void _P(T &&_t, U &&..._u) { cout << _t << " ", _P(_u...); }

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

inline int getRand(int L, int R) {
    if (L > R) swap(L, R);
    return (int)(rng() % ((uint64_t)R - L + 1) + L);
}

template <typename T, typename U> bool chmin(T &lhs, U rhs) { return lhs > rhs ? lhs = rhs, 1 : 0; }
template <typename T, typename U> bool chmax(T &lhs, U rhs) { return lhs < rhs ? lhs = rhs, 1 : 0; }

/// below are Fast I/O and _print_err templates ///

/*
/// Fast I/O by FHVirus ///
/// https://fhvirus.github.io/blog/2020/fhvirus-io/ ///

#include <unistd.h>

const int S = 65536;

int OP = 0;
char OB[S];

inline char RC() {
    static char buf[S], *p = buf, *q = buf;
    return p == q and (q = (p = buf) + read(0, buf, S)) == buf ? -1 : *p++;
}

inline int RI() {
    static char c;
    int a;
    while (((c = RC()) < '0' or c > '9') and c != '-' and c != -1);
    if (c == '-') {
        a = 0;
        while ((c = RC()) >= '0' and c <= '9') a *= 10, a -= c ^ '0';
    }
    else {
        a = c ^ '0';
        while ((c = RC()) >= '0' and c <= '9') a *= 10, a += c ^ '0';
    }
    return a;
}

inline void WI(int n, char c = '\n') {
    static char buf[20], p;
    if (n == 0) OB[OP++] = '0';
    p = 0;
    if (n < 0) {
        OB[OP++] = '-';
        while (n) buf[p++] = '0' - (n % 10), n /= 10;
    }
    else {
        while (n) buf[p++] = '0' + (n % 10), n /= 10;
    }
    for (--p; p >= 0; --p) OB[OP++] = buf[p];
    OB[OP++] = c;
    if (OP > S-20) write(1, OB, OP), OP = 0;
}

/// Fast I/O by FHVirus ///
/// https://fhvirus.github.io/blog/2020/fhvirus-io/ ///
*/

#ifdef local

template <typename T> inline void _print_err(T &&_t) { cerr << _t; }

template <typename T> inline void _print_err(T &&_t) requires is_iterable<T> and (not is_string<T>) {
    _color.emplace_back(_color.back()), ++_color.back()[3];
    cerr << _color.back() << "[";
    for (bool _first = true; auto &_x : _t) {
        if (!_first) cerr << ", ";
        _print_err(_x), _first = false;
    }
    cerr << "]" << (_color.pop_back(), _color.back());
}

template <typename T, typename U> ostream& operator << (ostream &os, const pair<T, U> &_tu) {
    _color.emplace_back(_color.back()), ++_color.back()[3];
    cerr << _color.back() << "(";
    _print_err(_tu.first), cerr << ", ", _print_err(_tu.second);
    cerr << ")" << (_color.pop_back(), _color.back());
    return os;
}

template <size_t I = 0, typename ...U> inline typename enable_if<I == sizeof...(U), void>::type _print_err(const tuple<U...> &) {
    cerr << ")" << (_color.pop_back(), _color.back());
}

template <size_t I = 0, typename ...U> inline typename enable_if<I <  sizeof...(U), void>::type _print_err(const tuple<U...> &_t) {
    if (!I) {
        _color.emplace_back(_color.back()), ++_color.back()[3];
        cerr << _color.back();
    }
    cerr << (I ? ", " : "("), _print_err(get<I>(_t)), _print_err<I+1, U...>(_t);
}

template <size_t I = 0, typename ...U> inline typename enable_if<I == sizeof...(U), void>::type _print_err(tuple<U...> &) {
    cerr << ")" << (_color.pop_back(), _color.back());
}

template <size_t I = 0, typename ...U> inline typename enable_if<I <  sizeof...(U), void>::type _print_err(tuple<U...> &_t) {
    if (!I) {
        _color.emplace_back(_color.back()), ++_color.back()[3];
        cerr << _color.back();
    }
    cerr << (I ? ", " : "("), _print_err(get<I>(_t)), _print_err<I+1, U...>(_t);
}

#endif

#endif

/**
 *                                                                                                                 
 *                                                                                                                 
 *                                                                                                                 
 *                            iiiiii         iiiiiiiiii       iiiiiiiiiiiiii                                       
 *                       iiiiiiiiiiiii   iiiiiii    iiii    iiiiiiiiiiiiiii                          ii   iiii     
 *                    iiiiiiii     iiiiiiiii         iiii       iiii iii              iii          iiiiiiiiii      
 *                 iiiiiii          iiiiii           iiii    iiii   ii           iiiiiiiiii      iiii iiii         
 *               iiiiii            iiiii             iiii iiii        iii      iiii    iiiiiiiiiiiiiiiii  ii       
 *             iiiiii            iiiiiii            iiiiiii       iiiiiiii   iii    iiiiiiiiiiiiii iii  iiii       
 *           iiiiii             iiiiiii            iiiii   ii   iiii       iiiiiiiiiii iiii  iii iiii iiii      iii
 *          iiiii              iiiiiiii       ii        iiiii iiii    iiiiiiiii        iii iii  iii  iii  ii  iiii 
 *        iiiiii              iiiiiiii      iiiii     iiiii iiiiiiiiiiiiiiii         iii  iii  ii  iii  iii iiii   
 *       iiiii                 iiiiii     iiii     iiiiii iiiiiii    iii iii       iiii  ii   i   ii  iii  iii     
 *     iiiiii                            iiii  iiiiiiiiiiiiiii       iii iiii   iiiii  iii  ii  iii  iii  ii       
 *    iiiii                              iiiiiiii iiiiiiiiii       iiii   iiiiiiiii            ii  iii  ii         
 *   iiiii                                     iiiiii  iiii      iiiii              iii      ii   ii  i            
 * iiiiii                                  iiiiiiii   iiiii    iiiii                        ii  ii   ii            
 * iiiii                                iiii  iiii    iiiiiiiiiiii                             ii                  
 *  iii                              iiii   iiii       iiiiiiii                                                    
 *                                iiiii   iiii                                                                     
 *                              iiii     iiii                                                                      
 *                            iiii    iiiii                                                                        
 *                          iii     iiiii                                                                          
 *                        iii     iiiii                                                                            
 *                       iii   iiiiii                                                                              
 *                       iiiiiiiii                                                                                 
 *                       iiiiii                                                                                    
 *                                                                                                                 
 *                                                                                                                 
 *                                                                                                                 
**/

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 4032kb

input:

1 1 1 1

output:

1 2 3 4
1.000000000000000 1.000000000000000 1.000000000000000 1.000000000000000

result:

ok all checks passed

Test #2:

score: 0
Accepted
time: 0ms
memory: 3892kb

input:

7 5 3 5

output:

2 1 3 4
4.000000000000000 7.000000000000000 3.000000000000000 5.000000000000000

result:

ok all checks passed

Test #3:

score: 0
Accepted
time: 0ms
memory: 3824kb

input:

2 3 4 5

output:

2 1 4 3
2.333333333333333 2.000000000000000 5.000000000000000 4.000000000000000

result:

ok all checks passed

Test #4:

score: 0
Accepted
time: 0ms
memory: 3860kb

input:

1 2 2 1

output:

1 2 4 3
1.000000000000000 2.000000000000000 1.000000000000000 2.000000000000000

result:

ok all checks passed

Test #5:

score: 0
Accepted
time: 0ms
memory: 3764kb

input:

2 3 3 2

output:

1 2 4 3
2.000000000000000 3.000000000000000 2.000000000000000 3.000000000000000

result:

ok all checks passed

Test #6:

score: 0
Accepted
time: 0ms
memory: 3824kb

input:

3 2 2 3

output:

1 2 4 3
3.000000000000000 2.000000000000000 3.000000000000000 2.000000000000000

result:

ok all checks passed

Test #7:

score: 0
Accepted
time: 0ms
memory: 3860kb

input:

3 2 1 3

output:

2 1 3 4
1.000000000000000 3.000000000000000 1.000000000000000 3.000000000000000

result:

ok all checks passed

Test #8:

score: 0
Accepted
time: 0ms
memory: 4044kb

input:

2 4 2 4

output:

1 2 3 4
2.000000000000000 4.000000000000000 2.000000000000000 4.000000000000000

result:

ok all checks passed

Test #9:

score: 0
Accepted
time: 0ms
memory: 3892kb

input:

4 4 2 2

output:

1 2 3 4
4.000000000000000 4.000000000000000 2.000000000000000 2.000000000000000

result:

ok all checks passed

Test #10:

score: 0
Accepted
time: 0ms
memory: 3904kb

input:

3 1 2 4

output:

3 1 2 4
1.000000000000000 3.000000000000000 1.000000000000000 4.000000000000000

result:

ok all checks passed

Test #11:

score: 0
Accepted
time: 0ms
memory: 3976kb

input:

3 3 5 2

output:

1 3 4 2
3.000000000000000 5.000000000000000 2.000000000000000 3.000000000000000

result:

ok all checks passed

Test #12:

score: 0
Accepted
time: 0ms
memory: 3852kb

input:

3 2 3 5

output:

1 2 4 3
3.000000000000000 2.000000000000000 5.000000000000000 3.000000000000000

result:

ok all checks passed

Test #13:

score: 0
Accepted
time: 0ms
memory: 3972kb

input:

5 6 9 9

output:

2 1 3 4
5.000000000000000 5.000000000000000 9.000000000000000 9.000000000000000

result:

ok all checks passed

Test #14:

score: 0
Accepted
time: 0ms
memory: 3944kb

input:

7 10 9 8

output:

4 1 2 3
7.750000000000000 7.000000000000000 10.000000000000000 9.000000000000000

result:

ok all checks passed

Test #15:

score: 0
Accepted
time: 0ms
memory: 3924kb

input:

3 2 6 11

output:

1 2 4 3
3.000000000000000 2.000000000000000 11.000000000000000 6.000000000000000

result:

ok all checks passed

Test #16:

score: 0
Accepted
time: 0ms
memory: 3824kb

input:

6 3 2 11

output:

1 3 4 2
6.000000000000000 2.000000000000000 11.000000000000000 3.000000000000000

result:

ok all checks passed

Test #17:

score: 0
Accepted
time: 0ms
memory: 3892kb

input:

233 169 120 175

output:

2 1 3 4
159.666666666666667 233.000000000000000 120.000000000000000 175.000000000000000

result:

ok all checks passed

Test #18:

score: 0
Accepted
time: 0ms
memory: 3860kb

input:

239 236 238 236

output:

2 3 4 1
235.012605042016807 238.000000000000000 236.000000000000000 239.000000000000000

result:

ok all checks passed

Test #19:

score: 0
Accepted
time: 0ms
memory: 4044kb

input:

2 240 2 240

output:

1 2 3 4
2.000000000000000 240.000000000000000 2.000000000000000 240.000000000000000

result:

ok all checks passed

Test #20:

score: 0
Accepted
time: 0ms
memory: 3832kb

input:

240 240 2 2

output:

1 2 3 4
240.000000000000000 240.000000000000000 2.000000000000000 2.000000000000000

result:

ok all checks passed

Test #21:

score: 0
Accepted
time: 0ms
memory: 4028kb

input:

339 288 167 164

output:

4 2 3 1
141.952662721893491 288.000000000000000 167.000000000000000 339.000000000000000

result:

ok all checks passed

Test #22:

score: 0
Accepted
time: 0ms
memory: 3900kb

input:

718 717 719 716

output:

2 3 4 1
716.997210599721060 719.000000000000000 716.000000000000000 718.000000000000000

result:

ok all checks passed

Test #23:

score: 0
Accepted
time: 0ms
memory: 3980kb

input:

91 9 145 6

output:

1 3 4 2
91.000000000000000 145.000000000000000 6.000000000000000 9.000000000000000

result:

ok all checks passed

Test #24:

score: 0
Accepted
time: 0ms
memory: 3976kb

input:

2 721 5 181

output:

1 3 4 2
2.000000000000000 5.000000000000000 181.000000000000000 721.000000000000000

result:

ok all checks passed

Test #25:

score: 0
Accepted
time: 0ms
memory: 3900kb

input:

3338 4625 1223 3820

output:

1 2 3 4
1480.583136946844724 4625.000000000000000 1223.000000000000000 3820.000000000000000

result:

ok all checks passed

Test #26:

score: 0
Accepted
time: 0ms
memory: 3840kb

input:

4759 4757 4757 4759

output:

1 2 4 3
4759.000000000000000 4757.000000000000000 4759.000000000000000 4757.000000000000000

result:

ok all checks passed

Test #27:

score: 0
Accepted
time: 0ms
memory: 3892kb

input:

70 530 10 70

output:

1 2 3 4
70.000000000000000 530.000000000000000 10.000000000000000 70.000000000000000

result:

ok all checks passed

Test #28:

score: 0
Accepted
time: 0ms
memory: 3952kb

input:

24 208 70 70

output:

1 3 4 2
24.000000000000000 70.000000000000000 70.000000000000000 208.000000000000000

result:

ok all checks passed

Test #29:

score: 0
Accepted
time: 0ms
memory: 3820kb

input:

708 2416 3273 2255

output:

4 1 3 2
958.889855072463768 708.000000000000000 3273.000000000000000 2416.000000000000000

result:

ok all checks passed

Test #30:

score: 0
Accepted
time: 0ms
memory: 3836kb

input:

5038 5039 5040 5038

output:

1 2 4 3
5037.000396904147648 5039.000000000000000 5038.000000000000000 5040.000000000000000

result:

ok all checks passed

Test #31:

score: 0
Accepted
time: 0ms
memory: 4036kb

input:

72 72 72 72

output:

1 2 3 4
72.000000000000000 72.000000000000000 72.000000000000000 72.000000000000000

result:

ok all checks passed

Test #32:

score: 0
Accepted
time: 0ms
memory: 3896kb

input:

5042 2 2 5042

output:

1 2 4 3
5042.000000000000000 2.000000000000000 5042.000000000000000 2.000000000000000

result:

ok all checks passed

Test #33:

score: 0
Accepted
time: 0ms
memory: 3900kb

input:

8117 5688 5949 4468

output:

4 2 3 1
4168.850665352390340 5688.000000000000000 5949.000000000000000 8117.000000000000000

result:

ok all checks passed

Test #34:

score: 0
Accepted
time: 0ms
memory: 3840kb

input:

9997 9997 9996 9994

output:

3 1 4 2
9994.000000000000000 9997.000000000000000 9994.000000000000000 9997.000000000000000

result:

ok all checks passed

Test #35:

score: 0
Accepted
time: 0ms
memory: 3888kb

input:

770 14 9998 2

output:

1 3 4 2
770.000000000000000 9998.000000000000000 2.000000000000000 14.000000000000000

result:

ok all checks passed

Test #36:

score: 0
Accepted
time: 0ms
memory: 4044kb

input:

2 9998 9998 2

output:

1 2 4 3
2.000000000000000 9998.000000000000000 2.000000000000000 9998.000000000000000

result:

ok all checks passed

Test #37:

score: 0
Accepted
time: 0ms
memory: 3904kb

input:

5234 6415 7116 2817

output:

1 3 4 2
3124.766760212036171 7116.000000000000000 2817.000000000000000 6415.000000000000000

result:

ok all checks passed

Test #38:

score: 0
Accepted
time: 0ms
memory: 4036kb

input:

10000 9997 9996 9996

output:

3 2 4 1
9993.001200120012001 9997.000000000000000 9996.000000000000000 10000.000000000000000

result:

ok all checks passed

Test #39:

score: 0
Accepted
time: 0ms
memory: 3828kb

input:

2 201 51 10000

output:

3 1 4 2
50.995000000000000 2.000000000000000 10000.000000000000000 201.000000000000000

result:

ok all checks passed

Test #40:

score: 0
Accepted
time: 0ms
memory: 3892kb

input:

2501 626 17 5

output:

1 2 3 4
2501.000000000000000 626.000000000000000 17.000000000000000 5.000000000000000

result:

ok all checks passed