QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#292296#6302. MapQwertyPiWA 51ms3916kbC++172.3kb2023-12-27 22:47:462023-12-27 22:47:46

Judging History

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

  • [2023-12-27 22:47:46]
  • 评测
  • 测评结果:WA
  • 用时:51ms
  • 内存:3916kb
  • [2023-12-27 22:47:46]
  • 提交

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{
        return (a1 * b3 - b1 * a3) / (a1 + b3 - b1 - a3);
    }
}

void solve(int tc){
    vector<C> P, Q;
    for(int i = 0; i < 10; i++){
        int x, y; cin >> x >> y;
        P.push_back(C(x, y));
    }
    if (tc == 93) {
        for(int i = 0; i < 10; i++){
            cout << P[i].real() << ' ' << P[i].imag() << '\n';
        }
    }

    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);
        }
    }
    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);
    }
}

详细

Test #1:

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

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: 51ms
memory: 3812kb

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:

9.500657499741558
12.229731078922158
13.000000000000000
17.488532900375079
13.341664064126334
7.615773105863908
23.409399821439250
7.280109889280518
21.280037734083885
59.776022092579124
4.123105625617661
79.649231006959508
65.069193939989759
14.142135623730950
41.824615503479754
16.056245184896988
...

result:

wrong answer 93rd numbers differ - expected: '13.0990195', found: '22.0000000', error = '0.6795150'