QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#553645#8676. Three Kinds of DiceRngBased#WA 85ms11492kbC++173.7kb2024-09-08 17:06:272024-09-08 17:06:31

Judging History

你现在查看的是最新测评结果

  • [2024-09-08 17:06:31]
  • 评测
  • 测评结果:WA
  • 用时:85ms
  • 内存:11492kb
  • [2024-09-08 17:06:27]
  • 提交

answer

#include <bits/stdc++.h>
#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pdd pair<double, double>
#define F first
#define S second 
#define all(x) x.begin(), x.end()
using namespace std;

const double eps = 1e-9;
pdd operator+(pdd a, pdd b)
{
    return pdd(a.F + b.F, a.S + b.S);
}
pdd operator-(pdd a)
{
    return pdd(-a.F, -a.S);
}
pdd operator-(pdd a, pdd b)
{
    return a + (-b);
}
pdd operator*(pdd a, double b)
{
    return pdd(a.F * b, a.S * b);
}
pdd operator/(pdd a, double b)
{
    return pdd(a.F / b, a.S / b);
}
double dot(pdd a, pdd b)
{
    return a.F * b.F + a.S * b.S;
}
double abs2(pdd a)
{
    return dot(a, a);
}
int sign(double d)
{
    return fabs(d) < eps ? 0 : (d < 0 ? -1 : 1);
}
double cross(pdd a, pdd b)
{
    return a.F * b.S - a.S * b.F;
}
int ori(pdd a, pdd b, pdd c)
{
    return sign(cross(b - a, c - a));
}
void convex(vector<pdd> &dots)
{
    sort(all(dots));
    vector<pdd> ans(1, dots[0]);
    for (int ct = 0; ct < 2; ++ct, reverse(all(dots)))
        for (int i = 1, t = ans.size(); i < dots.size(); ans.emplace_back(dots[i++]))
            while(ans.size() > t && ori(ans.end()[-2], ans.back(), dots[i]) <= 0)
                ans.pop_back();
    ans.pop_back(), ans.swap(dots);
}
bool collinear(pdd p1, pdd p2, pdd p3)
{
    return ori(p1, p2, p3) == 0;
}
bool btw(pdd p1, pdd p2, pdd p3)
{
    return collinear(p1, p2, p3) && sign(dot(p1 - p3, p2 - p3)) <= 0;
}
bool seg_intersect(pdd p1, pdd p2, pdd p3, pdd p4)
{
    int a123 = ori(p1, p3, p4);
    int a124 = ori(p1, p2, p4);
    int a341 = ori(p3, p4, p1);
    int a342 = ori(p3, p4, p2);
    if (a123 == 0 && a124 == 0)
        return btw(p1, p2, p3) || btw(p1, p2, p4) || btw(p3, p4, p1) || btw(p3, p4, p2);
    return a123 * a124 <= 0 && a341 * a342 <= 0;
}


int n;
vector<int> d[2], v;

signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    
    cin >> n;
    d[0].resize(n);
    for (auto &i : d[0])
        cin >> i;
    cin >> n;
    d[1].resize(n);
    for (auto &i : d[1])
        cin >> i;

    for (int i : d[0]) 
        v.emplace_back(max(1, i - 1)), 
        v.emplace_back(i),
        v.emplace_back(i + 1);
    for (int i : d[1]) 
        v.emplace_back(max(1, i - 1)), 
        v.emplace_back(i),
        v.emplace_back(i + 1);

    sort(all(d[0]));
    sort(all(d[1]));
    sort(all(v));
    v.resize(unique(all(v)) - v.begin());
    auto count = [&](int x, int i)
    {
        int win = lower_bound(all(d[i]), x) - d[i].begin();
        int tie = upper_bound(all(d[i]), x) - d[i].begin();
        return double(win + tie) / (d[i].size() * 2);
    };

    double rate = 0;
    for (auto x : d[1])
        rate += count(x, 0) / (d[1].size());
    if (rate >= 0.5)
        swap(d[0], d[1]);

    vector<pdd> hull;
    for (auto i : v)
    {
        pdd p;
        auto &[x, y] = p;
        x = count(i, 0);
        y = count(i, 1);
        hull.emplace_back(p);
    }
    convex(hull);
    double mi = 1, mx = 0;
    for (int i = 0; i < (int)hull.size(); i++)
    {
        int j = (i + 1) % (int)hull.size();
        if (sign(hull[i].F - 0.5) * sign(hull[j].F - 0.5) <= 0)
        {
            double y = (hull[i].S * (0.5 - hull[j].F) + hull[j].S * (hull[i].F - 0.5)) / (hull[i].F - hull[j].F);
            mi = min(mi, y);
        }
        if (sign(hull[i].S - 0.5) * sign(hull[j].S - 0.5) <= 0)
        {
            double x = (hull[i].F * (0.5 - hull[j].S) + hull[j].F * (hull[i].S - 0.5)) / (hull[i].S - hull[j].S);
            mx = max(mx, x);
        }
    }
    cout << fixed << setprecision(10) << mi << ' ' << mx << '\n';
    
}

详细

Test #1:

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

input:

3 2 4 9
3 1 6 8

output:

0.2916666667 0.7500000000

result:

ok 2 numbers

Test #2:

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

input:

3 1 6 8
6 2 2 4 4 9 9

output:

0.2916666667 0.7500000000

result:

ok 2 numbers

Test #3:

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

input:

1 1
1 2

output:

0.7500000000 0.0000000000

result:

ok 2 numbers

Test #4:

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

input:

5 2 2 2 3 3
6 5 5 6 6 6 7

output:

0.5000000000 0.5000000000

result:

ok 2 numbers

Test #5:

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

input:

6 2 2 7 7 9 9
6 3 3 5 5 10 10

output:

0.2500000000 0.7500000000

result:

ok 2 numbers

Test #6:

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

input:

11 12 11 15 9 3 8 18 4 17 13 9
11 8 18 5 15 12 5 11 11 11 3 8

output:

0.4736842105 0.5250000000

result:

ok 2 numbers

Test #7:

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

input:

20 17 18 29 37 5 15 5 9 37 34 12 38 26 29 2 40 23 20 4 12
23 22 2 24 33 6 19 15 31 1 18 30 11 40 13 2 19 5 39 37 22 9 31 26

output:

0.4405034325 0.5541666667

result:

ok 2 numbers

Test #8:

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

input:

40 52 22 29 52 44 3 69 45 40 73 66 51 2 21 20 51 49 34 72 64 69 68 56 4 6 39 29 18 43 6 56 15 22 31 25 78 59 58 40 66
46 52 24 40 12 56 7 4 29 12 26 45 39 27 47 55 45 17 74 28 12 75 77 77 73 41 21 20 23 55 13 58 21 43 11 22 2 67 18 49 56 15 26 25 35 20 61

output:

0.4339714471 0.5652243590

result:

ok 2 numbers

Test #9:

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

input:

76 54 80 5 41 10 124 87 45 67 42 118 33 128 118 21 40 41 3 18 69 131 113 121 106 99 72 108 85 101 108 72 27 13 45 133 137 4 62 30 111 71 39 31 120 79 91 30 58 43 6 60 65 83 83 42 83 26 108 20 133 24 8 125 138 100 21 103 81 45 102 76 44 118 109 18 67
81 4 15 26 65 110 48 126 39 128 82 1 43 134 18 69 ...

output:

0.4211886305 0.5737110634

result:

ok 2 numbers

Test #10:

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

input:

96 11 1 23 7 6 41 8 11 40 5 24 32 40 40 24 24 24 23 17 21 27 21 21 42 1 29 15 45 24 44 50 1 34 11 7 1 12 45 15 3 14 9 25 5 5 20 31 1 41 44 7 27 28 11 24 37 50 7 7 48 1 22 4 5 40 32 33 32 18 18 26 49 28 34 42 29 15 18 4 42 12 21 17 10 47 2 44 40 8 15 7 44 25 5 13 19
88 16 30 20 24 2 26 39 28 1 16 10 ...

output:

0.4818548387 0.5185950413

result:

ok 2 numbers

Test #11:

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

input:

208 31 110 162 24 386 12 262 283 384 392 361 168 58 129 155 45 36 70 2 127 296 380 188 125 148 77 117 272 219 38 79 322 70 91 115 273 228 375 398 353 277 307 258 60 42 60 298 109 60 158 192 159 29 165 103 51 304 313 392 113 62 149 203 152 3 373 206 144 136 214 151 348 287 181 202 367 67 138 388 93 3...

output:

0.4955877991 0.5044270833

result:

ok 2 numbers

Test #12:

score: 0
Accepted
time: 1ms
memory: 4024kb

input:

1170 1311 1924 962 906 1767 1811 1941 1956 1311 364 371 1825 1155 918 1625 1882 1082 198 889 924 1830 244 589 1639 296 1326 1663 379 1479 1369 729 1698 870 1845 217 888 754 858 966 1887 61 1801 1002 1185 1848 610 1914 1742 409 648 781 445 1217 96 1639 1681 1028 923 123 1234 909 569 747 1182 1538 368...

output:

0.4855426993 0.5141050030

result:

ok 2 numbers

Test #13:

score: 0
Accepted
time: 22ms
memory: 5480kb

input:

22713 21796 19194 13993 27763 16658 14855 3720 21919 4029 27311 21879 4981 25538 24982 5230 7339 4299 26976 30753 39183 38686 25483 3489 12855 28134 34477 25105 39953 31801 23937 31229 26076 32962 33965 6078 33306 15915 21622 3643 29726 2542 27764 4554 17811 17329 10576 26448 24416 30696 3230 3730 1...

output:

0.4995293383 0.5004706031

result:

ok 2 numbers

Test #14:

score: 0
Accepted
time: 8ms
memory: 5592kb

input:

100000 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...

output:

0.7500000000 0.0000000000

result:

ok 2 numbers

Test #15:

score: 0
Accepted
time: 7ms
memory: 5620kb

input:

1 1
100000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 100...

output:

0.7500000000 0.0000000000

result:

ok 2 numbers

Test #16:

score: 0
Accepted
time: 22ms
memory: 9380kb

input:

100000 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...

output:

0.7500000000 0.0000000000

result:

ok 2 numbers

Test #17:

score: 0
Accepted
time: 14ms
memory: 8812kb

input:

100000 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...

output:

0.5000050000 0.4999950000

result:

ok 2 numbers

Test #18:

score: 0
Accepted
time: 15ms
memory: 8600kb

input:

100000 1 1000000000 1 1000000000 1 1000000000 1 1000000000 1 1000000000 1 1000000000 1 1000000000 1 1000000000 1 1000000000 1 1000000000 1 1000000000 1 1000000000 1 1000000000 1 1000000000 1 1000000000 1 1000000000 1 1000000000 1 1000000000 1 1000000000 1 1000000000 1 1000000000 1 1000000000 1 10000...

output:

0.5000000000 0.5000000000

result:

ok 2 numbers

Test #19:

score: 0
Accepted
time: 85ms
memory: 11492kb

input:

100000 100000 99999 99998 99997 99996 99995 99994 99993 99992 99991 99990 99989 99988 99987 99986 99985 99984 99983 99982 99981 99980 99979 99978 99977 99976 99975 99974 99973 99972 99971 99970 99969 99968 99967 99966 99965 99964 99963 99962 99961 99960 99959 99958 99957 99956 99955 99954 99953 9995...

output:

0.5000000000 0.5000000000

result:

ok 2 numbers

Test #20:

score: 0
Accepted
time: 81ms
memory: 11308kb

input:

100000 100000 99999 99998 99997 99996 99995 99994 99993 99992 99991 99990 99989 99988 99987 99986 99985 99984 99983 99982 99981 99980 99979 99978 99977 99976 99975 99974 99973 99972 99971 99970 99969 99968 99967 99966 99965 99964 99963 99962 99961 99960 99959 99958 99957 99956 99955 99954 99953 9995...

output:

0.5000000000 0.5000000000

result:

ok 2 numbers

Test #21:

score: 0
Accepted
time: 27ms
memory: 8496kb

input:

99818 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 ...

output:

0.2126750390 0.7873208946

result:

ok 2 numbers

Test #22:

score: -100
Wrong Answer
time: 24ms
memory: 8812kb

input:

99536 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 ...

output:

0.0094052338 0.7476263670

result:

wrong answer 1st numbers differ - expected: '0.0093849', found: '0.0094052', error = '0.0000203'