QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#292310#6302. MapQwertyPiWA 1ms3752kbC++172.3kb2023-12-27 22:53:452023-12-27 22:53:46

Judging History

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

  • [2023-12-27 22:53:46]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3752kb
  • [2023-12-27 22:53:45]
  • 提交

answer

#include <bits/stdc++.h>

#define int long long
#define all(a) (a).begin(), (a).end()
#define sz(a) (int) (a).size()
#define forn(i, n) for(int i = 0; i < (n); i++)

using namespace std;

typedef long double LD;
typedef complex<LD> C;

ostream& operator<< (ostream& out, C z){
    return out << "(" << z.real() << ", " << z.imag() << ")";
}

LD eps = 1e-9;
int sgn(LD x){
    if(fabs(x) < eps) return 0;
    return x > 0 ? 1 : -1;
}

C reflect(C A, C B, C P){
    C Q = (P - A) / (B - A);
    Q.imag(-Q.imag());
    return A + Q * (B - A);
}

C calc_center(C a1, C a2, C a3, C b1, C b2, C b3){
    if(sgn(norm(a1 + b2 - a2 - b1))){
        return (a1 * b2 - b1 * a2) / (a1 + b2 - b1 - a2);
    }else if(sgn(norm(a1 + b3 - b1 - a3))){
        return (a1 * b3 - b1 * a3) / (a1 + b3 - b1 - a3);
    }else{
        return C(0, 0);
    }
}

void solve(int tc, bool hidden){
    vector<C> P, Q;
    for(int i = 0; i < 10; i++){
        int x, y; cin >> x >> y;
        P.push_back(C(x, y));
    }

    int dir_A = sgn(((P[2] - P[1]) / (P[1] - P[0])).imag());
    int dir_B = sgn(((P[6] - P[5]) / (P[5] - P[4])).imag());

    bool same_dir = dir_A == dir_B;

    if (!same_dir) {
        swap(P[4], P[5]); swap(P[6], P[7]);
    }

    C z = calc_center(P[0], P[1], P[2], P[4], P[5], P[6]);
    vector<C> R;
    for(int i = 0; i < 4; i++){
        R.push_back((P[i + 4] - z) / (P[i] - z));
    }
    C r = sgn(norm(P[0] - z)) ? R[0] : R[1];
    auto f = [&] (C p) {
        C q = z + r * (p - z);
        if (!same_dir) {
            q = reflect((P[4] + P[5]) * C(0.5, 0), (P[6] + P[7]) * C(0.5, 0), q);
        }
        return q;
    };
    int k, n; cin >> k >> n;
    LD ans = 1LL << 60;
    vector<C> ma, mb;
    forn(i, n + 1) ma.push_back(P[8]), P[8] = f(P[8]);
    forn(i, n + 1) mb.push_back(P[9]), P[9] = f(P[9]);
    for(int L = 0; L <= n; L++){
        for(int R = 0; R <= n - L; R++){
            C a = ma[L], b = mb[R];
            ans = min(ans, sqrtl(norm(a - b)) + (L + R) * k);
        }
    }
    if(!hidden) cout << ans << '\n';
}

int32_t main(){
    cin.tie(0); cout.tie(0)->sync_with_stdio(false);
    cout << setprecision(15) << fixed;
    int t = 1;
    cin >> t;
    for(int tc = 1; tc <= t; tc++){
        solve(tc, t >= 10);
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

2
0 0 0 2 4 2 4 0
0 0 0 1 2 1 2 0
2 1 4 2
1 1
0 0 0 3 6 3 6 0
0 1 1 0 3 2 2 3
0 0 4 2
0 3

output:

1.000000000000000
1.227262335243029

result:

ok 2 numbers

Test #2:

score: -100
Wrong Answer
time: 1ms
memory: 3616kb

input:

100
-133 -128 -109 -134 -85 -38 -109 -32
-95 -37 -100 -35 -108 -55 -103 -57
-119 -130 -112 -44
2 73
5 -100 5 -8 1 -8 1 -100
1 -60 1 -14 3 -14 3 -60
3 -84 1 -20
2 53
-58 -78 -66 -78 -66 -34 -58 -34
-58 -34 -66 -34 -66 -78 -58 -78
-63 -50 -63 -37
4 54
52 -148 116 -148 116 -52 52 -52
53 -103 53 -71 101...

output:


result:

wrong output format Unexpected end of file - double expected