QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#73250 | #2935. Spider-Fly | qdd# | WA | 2ms | 3672kb | C++20 | 4.2kb | 2023-01-23 09:02:16 | 2023-01-23 09:02:18 |
Judging History
answer
// qdd on Jan 22, 2023
#ifdef qdd
#include <ringo>
#else
#include <bits/stdc++.h>
#define dbg(...)
#define dbgr(x, y)
#endif
using namespace std;
using ll = long long;
#define ALL(x) begin(x), end(x)
template <class T>
istream& operator>>(istream& is, vector<T>& v) {
for (T& x : v) is >> x;
return is;
}
template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
bool f = 0;
for (const T& x : v) (f ? os << ' ' : os) << x, f = 1;
return os;
}
using ld = double;
ld W, H, L;
struct P {
ld x, y, z;
P() {}
P(ld x, ld y, ld z) : x(x), y(y), z(z) {}
int get_face() {
if (z == 0) return 5;
if (z == L) return 6;
if (y == 0) return 1;
if (y == H) return 3;
if (x == 0) return 2;
if (x == W) return 4;
assert(0);
}
P operator-(const P& b) const { return P(x - b.x, y - b.y, z - b.z); }
};
ostream& operator<<(ostream& os, const P& p) { return os << "(" << p.x << ", " << p.y << ", " << p.z << ")"; }
struct F {
ld x, y;
ld h, w;
ld offset_x, offset_y;
F() { offset_x = offset_y = 0; }
F(P p) {
int f = p.get_face();
assert(f == 5 || f == 6);
h = H;
w = W;
if (f == 5) {
x = p.x;
y = p.y;
offset_x = 0;
offset_y = 0;
} else {
x = p.x;
y = H - p.y;
offset_x = 0;
offset_y = -L - H;
}
}
void rot_cw() {
ld _x = y;
ld _y = w - x;
x = _x;
y = _y;
swap(h, w);
}
void rot_ccw() {
rot_cw();
rot_cw();
rot_cw();
}
void add(ld xx, ld yy) {
offset_x += xx;
offset_x += yy;
}
ld getx() { return x + offset_x; }
ld gety() { return y + offset_y; }
};
P s, t;
ld dis(P a, P b) {
P c = a - b;
return sqrt(c.x * c.x + c.y * c.y + c.z * c.z);
}
ld dis(F a, F b) {
ld x = a.getx() - b.getx(), y = a.gety() - b.gety();
return sqrt(x * x + y * y);
}
P transform_2(P p) {
int f = p.get_face();
int x = p.x, y = p.y, z = p.z;
assert(f >= 1 && f <= 4);
if (f == 1) return P(x, 0, z);
if (f == 2) return P(-y, 0, z);
if (f == 3) return P(2 * W + H - x, 0, z);
if (f == 4) return P(W + y, 0, z);
return P();
}
ld sol3() {
F a = F(s);
F b = F(t);
vector<F> up, down;
for (int i = 0; i < 8; i++) {
up.push_back(a);
a.rot_cw();
a.add(a.h, 0);
}
for (int i = 0; i < 8; i++) {
down.push_back(b);
b.rot_ccw();
b.add(b.h, b.w - b.h);
}
// for (int i = 0; i < 8; i++) {
// cout << up[i].getx() << ' ' << up[i].gety() << '\n';
// // cout << down[i].x << ' ' << down[i].y << '\n';
// cout << "---";
// }
// dbg(">>> here");
// for (int i = 0; i < 8; i++) {
// // cout << up[i].x << ' ' << up[i].y << '\n';
// cout << down[i].x << ' ' << down[i].y << '\n';
// cout << "---";
// }
ld ans = 1e18;
for (int i = 0; i < 8; i++) {
for (int j = 0; j < 8; j++) {
ans = min(ans, dis(up[i], down[j]));
}
}
return ans;
}
void sol() {
cin >> W >> H >> L;
cin >> s.x >> s.y >> s.z;
cin >> t.x >> t.y >> t.z;
if (s.get_face() == t.get_face()) {
cout << dis(s, t) << '\n';
return;
}
for (int i = 0; i < 27; i++) {
tie(W, H, L) = make_tuple(H, L, W);
tie(s.x, s.y, s.z) = make_tuple(s.y, s.z, s.x);
tie(t.x, t.y, t.z) = make_tuple(t.y, t.z, t.x);
int fs = s.get_face();
int ft = t.get_face();
if (fs > ft) {
swap(fs, ft), swap(s, t);
}
if (fs <= 4 && ft <= 4 && (fs % 4 + 1) == ft) {
P a = transform_2(s);
P b = transform_2(t);
if (fs == 2 && ft == 3) {
a.x += W * 2 + H * 2;
}
cout << dis(a, b) << '\n';
return;
}
}
// sol3
while (s.get_face() != 5 && t.get_face() != 6) {
tie(W, H, L) = make_tuple(H, L, W);
tie(s.x, s.y, s.z) = make_tuple(s.y, s.z, s.x);
tie(t.x, t.y, t.z) = make_tuple(t.y, t.z, t.x);
int fs = s.get_face();
int ft = t.get_face();
if (fs > ft) {
swap(fs, ft), swap(s, t);
}
}
cout << sol3() << '\n';
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout << fixed << setprecision(6);
sol();
return 0;
}
详细
Test #1:
score: 0
Wrong Answer
time: 2ms
memory: 3672kb
input:
12 12 30 6 11 0 6 1 30
output:
40.000000
result:
wrong answer 1st lines differ - expected: '40.000', found: '40.000000'