QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#292309 | #6302. Map | QwertyPi | WA | 0ms | 3788kb | C++17 | 2.5kb | 2023-12-27 22:53:08 | 2023-12-27 22:53:09 |
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 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));
}
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]);
cout << z << endl;
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: 0
Wrong Answer
time: 0ms
memory: 3788kb
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:
(0.000000000000000, 0.000000000000000) 1.000000000000000 (1.200000000000000, 0.600000000000000) 1.227262335243029
result:
wrong output format Expected double, but "(0.000000000000000," found