QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#292302 | #6302. Map | QwertyPi | WA | 51ms | 3816kb | C++17 | 2.4kb | 2023-12-27 22:49:31 | 2023-12-27 22:49:31 |
Judging History
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, 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));
}
if (tc == 93) {
for(int i = 0; i < 10; i++){
cout << (int) P[i].real() << ' ' << (int) 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);
}
}
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);
}
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3816kb
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: 3456kb
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:
22 125 22 186 19 186 19 125 22 186 22 125 19 125 19 186 22 138 21 178
result:
wrong answer 1st numbers differ - expected: '9.5006575', found: '22.0000000', error = '1.3156292'