QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#796028#9808. Fragile Pinballucup-team3099#WA 0ms4012kbC++236.2kb2024-12-01 06:34:352024-12-01 06:34:35

Judging History

This is the latest submission verdict.

  • [2024-12-01 06:34:35]
  • Judged
  • Verdict: WA
  • Time: 0ms
  • Memory: 4012kb
  • [2024-12-01 06:34:35]
  • Submitted

answer

#include <iostream>
#include <vector>
#include <chrono>
#include <random>
#include <cassert>
#include <algorithm>
#include <iomanip>

std::mt19937 rng((int) std::chrono::steady_clock::now().time_since_epoch().count());

struct PT {
    typedef long double T;
    T x, y;
    PT(T _x = 0, T _y = 0) : x(_x), y(_y){}
    PT operator +(const PT &p) const { return PT(x+p.x,y+p.y); }
    PT operator -(const PT &p) const { return PT(x-p.x,y-p.y); }
    PT operator *(T c)         const { return PT(x*c,y*c);     }
    PT operator /(long double c)    const { return PT(x/c,y/c);     }
    T operator *(const PT &p)  const { return x*p.x+y*p.y;     }
    T operator %(const PT &p)  const { return x*p.y-y*p.x;     }
    long double operator !()        const { return hypotl(x, y);   }
    long double operator ^(const PT &p) const { return atan2l(*this%p, *this*p);}

    friend std::ostream& operator << (std::ostream &os, const PT &p) {
        return os << p.x << ' ' << p.y;
    }
    friend std::istream& operator >> (std::istream &is, PT &p) {
        return is >> p.x >> p.y;
    }
};

const long double eps = 1e-15;

int n;
long double ans[7];

template<class P>
P lineProj(P a, P b, P p, bool refl=false) {
    P v = b - a;
    return p - P(-v.y, v.x)*(1+refl)*(v % (p-a))/(v * v);
}

template<class P>
std::pair<int, P> lineInter(P s1, P e1, P s2, P e2) {
    auto d = (e1 - s1) % (e2 - s2);
    auto p = (e1 - s2) % (e2 - s2), q = (e2 - s2) % (s1 - s2);
    return {1, (s1 * p + e1 * q) / d};
}

void go(std::vector<PT> hull, PT start, PT low, PT high, int bounces, int mask) {
    for(int i = 0; i < n; i++) {
        PT oriA = hull[i], oriB = hull[(i+1)%n];
        int oriId = bounces % 2 == 0 ? i : (n - (i + 1)) % n;
        PT A = oriA - start, B = oriB - start;
        if(A % B <= -eps) {
            continue;
        }
        PT newLow = low, newHigh = high;
        if(low % A > 0) {
            newLow = A;
        }
        if(B % high > 0) {
            newHigh = B;
        }
        if(newLow % newHigh <= eps) {
            continue;
        }
        ans[bounces] = std::max({ans[bounces],
            !(lineInter(oriA, oriB, start, newLow + start).second - start),
            !(lineInter(oriA, oriB, start, newHigh + start).second - start)
        });
        if(bounces + 1 <= n && (mask & (1 << oriId)) == 0) {
            // std::cout << "at bounce " << bounces << " bouncing at index " << oriId << '\n';
            // std::cout << newLow << ", " << newHigh << '\n';
            // std::cout << "got distances " << (!(lineInter(oriA, oriB, start, newLow + start).second - start)) << ", " << (!(lineInter(oriA, oriB, start, newHigh + start).second - start)) << '\n';
            // std::cout << "for points " << lineInter(oriA, oriB, start, newLow + start).second << ", " << lineInter(oriA, oriB, start, newHigh + start).second << '\n';
            // std::cout << "original is " << oriA << ", " << oriB << '\n';
            auto nxtHull = hull;
            for(auto &p : nxtHull) {
                p = lineProj(oriA, oriB, p, true);
            }
            std::reverse(nxtHull.begin() + 1, nxtHull.end());
            // for(auto p : nxtHull) {
            //     std::cout << p << ' ';
            // }
            // std::cout << '\n';
            go(nxtHull, start, newLow, newHigh, bounces+1, mask | (1 << oriId));
        }
    }
}

int main() {
    std::ios_base::sync_with_stdio(false); std::cin.tie(NULL);
    std::cin >> n;
    std::vector<PT> hull(n);
    for(int i = 0; i < n; i++) {
        std::cin >> hull[i];
    }
    for(int i = 1; i <= n; i++) {
        //std::cout << "starting for index " << i-1 << " which is " << hull[i%n] << '\n';
        go(hull, hull[i%n], (hull[(i+1)%n] - hull[i%n]), (hull[(i-1)%n] - hull[i%n]), 0, 0);
    }
    std::cout << std::fixed << std::setprecision(20);
    for(int i = 0; i <= n; i++) {
        if(i) ans[i] = std::max(ans[i-1], ans[i]);
        std::cout << ans[i] << (i == n ? '\n' : ' ');
    }
}

/*
NEVER FORGET TO:
    Look at the problem's constraints before coding.
How to cheese cf:
    Find a lower bound or upper bound for the problem. Have faith that it is the answer of the problem.
    If it isn't the answer, have more faith or change to another bound god by looking for a better bound.

    Trust guesses. Who has time to think? If people in div2 AC the problem it requires no proof since people don't prove things.

    You must draw cases. Thinking gets you nowhere, so draw cases and reach illogical conclusions from them.
    Sometimes drawing cases is bad because it takes too much time. Faster is to not think at all and just code a bruteforce solution.
    This is called "law of small numbers". If something works for small numbers, surely it works for big numbers.
    https://en.wikipedia.org/wiki/Faulty_generalization#Hasty_generalization don't mind the "faulty" part of it, in competitive programming mistakes are lightly punished
    Don't think about them being right or not, cf is a battle of intuition only.

    Be as stupid as possible in implementation. Trying to be smart is an easy way to get WA.

    Think about 2x2 cases for matrix problems and hope that everything works for the general case.

    Find a necessary condition and trust it to be sufficient. They're basically the same thing.

    Heuristics might speed up your code. Forget about complexity, it's only about ACing and not proving that your solution is good.

    For paths in a grid starting at (1, i) or something like that, assume that they never cross and do D&C

    Consider doing problems in reverse order of queries/updates

    For combinatorics problems, consider symmetry

    For problems that are similar to past problems, think about the differences betweem it and the current problem.
    Sometimes the difference makes no difference. Sometimes it does.

General strategy (MUST DO):
    Try to solve the problem with more restricted constraints.

About testing:
    Test n=1, a[i]=1, a[i]=n, etc. Basically, test low values. No need to test if pretests are strong, but if you get WA it's good.

This isn't a joke. Do it if you get stuck. It's shit practice in my opinion, but do it if you want AC.
*/

详细

Test #1:

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

input:

3
4 0
0 3
0 -1

output:

5.00000000000000000000 8.00000000000000000000 8.86818503879756340601 12.21002481088195582796

result:

ok 4 numbers

Test #2:

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

input:

3
4 0
0 3
0 2

output:

5.00000000000000000000 5.36656314599949527165 6.11191913849942517010 6.78220330441662831679

result:

ok 4 numbers

Test #3:

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

input:

3
4 0
0 3
0 1

output:

5.00000000000000000000 6.18465843842649082469 7.19522354274454488138 8.65343949929425340205

result:

ok 4 numbers

Test #4:

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

input:

3
62 -12
-48 100
-45 -96

output:

196.02295783912658835857 312.04173783276056028391 326.27847771877617755187 452.80712372911078536508

result:

ok 4 numbers

Test #5:

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

input:

3
90 99
-76 -57
99 84

output:

227.79815626997510885632 274.35230645776344957087 306.89177947709210375615 330.10518554643359467882

result:

ok 4 numbers

Test #6:

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

input:

3
-67 22
-86 12
-81 -12

output:

36.76955262170047127046 39.56397500565403616002 50.91685591710600820511 72.27758551745063941851

result:

ok 4 numbers

Test #7:

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

input:

3
71 -48
-81 2
-83 -44

output:

160.01249951175689324734 308.05679456756879500134 308.05679456756879500134 308.05679456756879500134

result:

ok 4 numbers

Test #8:

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

input:

3
44 -44
-31 -77
8 -98

output:

81.93900170248597799455 115.79266829979315255039 125.60604402992012824936 167.93649349697933670367

result:

ok 4 numbers

Test #9:

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

input:

3
40 91
-42 90
-5 -99

output:

195.25624189766635985244 378.87426679199884818616 378.87426679199884821392 378.87426679199884821392

result:

ok 4 numbers

Test #10:

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

input:

4
-10 -97
13 -98
90 50
42 97

output:

200.84820138602187641896 269.68734146533457932127 382.16606804049615697672 476.59926283039679295594 476.59926283039679295594

result:

ok 5 numbers

Test #11:

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

input:

4
39 89
-72 -94
87 -58
90 36

output:

214.03270778084362684079 413.74414660992380257665 413.74414660992380260440 502.96571824848038159694 595.01821265490545836974

result:

ok 5 numbers

Test #12:

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

input:

4
-6 -90
33 -75
4 97
-36 -69

output:

187.26718879718358179431 269.54944439736868391777 309.20805779551497013968 364.70165807157006576666 395.37828755440608743954

result:

ok 5 numbers

Test #13:

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

input:

4
44 81
27 81
60 -57
83 3

output:

141.89080308462560815752 187.12271495993614237041 251.47668954805475105552 274.12765684348474590215 286.31951740573043155291

result:

ok 5 numbers

Test #14:

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

input:

4
96 -13
99 1
-67 -36
67 -37

output:

170.07351351694948740634 183.08542624904550161213 223.21210351724533335616 277.37918419740198808232 306.15039727040056236063

result:

ok 5 numbers

Test #15:

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

input:

4
-18 -98
80 -59
73 68
-78 -62

output:

199.25109786397664915492 378.32587882437449527950 378.32587882437449527950 512.61754381185761964002 557.38745761591020327907

result:

ok 5 numbers

Test #16:

score: -100
Wrong Answer
time: 0ms
memory: 3972kb

input:

5
-90 41
-93 27
94 79
83 91
-44 94

output:

194.09533739891847282932 206.35552445442488619931 256.73130200089089886228 337.34690346234038338391 377.92916040834781452040 377.92916040834781452040

result:

wrong answer 6th numbers differ - expected: '396.6629387', found: '377.9291604', error = '0.0472285'