QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#26021 | #2839. 3D Geometry | Hakujitsu | AC ✓ | 251ms | 3928kb | C++ | 2.3kb | 2022-04-05 21:39:13 | 2022-04-29 02:44:39 |
Judging History
answer
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#include <bits/stdc++.h>
using namespace std;
void debug_out() {cerr << endl;}
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T)
{
cerr << " " << H;
debug_out(T...);
}
#ifndef ONLINE_JUDGE
#define debug(...) cerr << "{" << #__VA_ARGS__ << "}:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif
using db = double;
db x[2], y[2], z[2];
db a[2], b[2], c[2];
int main(){
ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
cout << fixed << setprecision(15);
cerr << fixed << setprecision(15);
while(cin >> a[0] >> b[0] >> c[0] >> a[1] >> b[1] >> c[1]) {
for (int i = 0; i < 2; i += 1) {
cin >> x[i] >> y[i] >> z[i];
}
if(a[0] > a[1]) {
x[0] = -x[0];
x[1] = -x[1];
a[0] = -a[0];
a[1] = -a[1];
}
if(b[0] > b[1]) {
y[0] = -y[0];
y[1] = -y[1];
b[0] = -b[0];
b[1] = -b[1];
}
if(c[0] > c[1]) {
c[0] = -c[0];
c[1] = -c[1];
z[0] = -z[0];
z[1] = -z[1];
}
if(x[0] > x[1]) swap(x[0], x[1]);
if(y[0] > y[1]) swap(y[0], y[1]);
if(z[0] > z[1]) swap(z[0], z[1]);
double res = 0;
for (int mask = 0; mask < 8; mask += 1) {
db cz = min(c[1], max(c[0], z[mask >> 2 & 1]));
db r = (c[1] - cz) / (c[1] - c[0]);
db cx = min(a[0] + (a[1] - a[0]) * r, max(a[0], x[mask >> 0 & 1]));
db cy = min(b[0] + (b[1] - b[0]) * r, max(b[0], y[mask >> 1 & 1]));
if(abs(r) < 1e-10) continue;
db r1 = (a[0] + (a[1] - a[0]) * r - cx) / (a[1] - a[0]) / r;
db xx = (b[1] - b[0]) * r * r1;
db yy = (b[1] - b[0]);
xx -= cy - b[0];
if(xx < 0) continue;
db r2 = 0;
if(abs(yy) > 1e-10) {
r2 = xx / yy;
}
if(__builtin_parity(mask)) {
res -= r2 * r2 * r2;
}
else res += r2 * r2 * r2;
}
res *= (a[1] - a[0]) * (b[1] - b[0]) * (c[1] - c[0]) / 6;
cout << res << "\n";
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 3ms
memory: 3788kb
input:
0 0 0 1 1 1 0 0 0 1 1 1 0 0 0 2 2 2 0 0 0 1 1 1 0 2 0 2 0 2 1 0 1 0 1 0
output:
0.166666666666667 0.833333333333333 0.166666666666667
result:
ok 3 numbers
Test #2:
score: 0
Accepted
time: 220ms
memory: 3784kb
input:
-3 -4 2 -5 -5 4 0 0 3 3 4 2 1 5 2 -4 0 0 5 -5 0 -2 -1 3 5 4 2 3 -5 -1 0 -2 -1 -4 -4 -3 -4 4 -2 -2 2 -1 2 2 1 4 0 5 -4 1 0 -5 -2 4 -5 2 -4 5 0 1 2 5 1 -1 0 -3 -1 5 -4 -4 2 -2 2 2 -4 1 3 -1 2 4 2 -2 1 3 2 5 2 -2 -3 -5 -1 0 0 5 4 2 2 5 3 -3 -3 -3 5 4 -4 1 2 -3 2 -4 2 -3 -2 -2 2 -2 -1 -4 -5 3 4 -3 -3 -3...
output:
0.000000000000000 0.000000000000000 0.000000000000000 0.000000000000000 0.708333333333333 0.000000000000000 0.000000000000000 15.355654761904763 0.000000000000000 6.562500000000000 0.000000000000000 0.000000000000000 -0.000000000000000 0.000000000000000 0.000000000000000 0.000000000000000 0.00000000...
result:
ok 100000 numbers
Test #3:
score: 0
Accepted
time: 229ms
memory: 3928kb
input:
-2 -2 -9 1 7 6 -3 -1 -4 -5 -6 2 -3 -4 -9 -10 -5 -4 0 2 -6 7 -9 2 6 4 5 -2 -6 0 8 -8 -3 -3 -10 2 10 -3 -8 -7 -5 -10 -9 -5 1 10 8 -1 7 9 10 6 3 9 -10 -10 -4 0 2 1 -2 4 9 10 5 -4 -6 6 3 7 4 8 6 5 2 3 -7 8 2 3 1 4 -10 7 -7 -3 -6 -10 5 -9 0 3 1 -5 -6 8 5 -3 8 -8 -8 -4 5 -10 4 0 3 1 9 -9 0 -8 8 -3 -7 9 -2...
output:
0.000000000000000 0.000000000000000 0.000000000000000 0.000000000000000 0.000000000000000 16.255732248520708 0.166666666666667 0.000000000000000 26.201923076923077 1.449891067538125 0.000000000000000 0.000000000000000 0.000000000000000 0.000000000000000 1.280276816608996 0.000000000000000 0.00000000...
result:
ok 100000 numbers
Test #4:
score: 0
Accepted
time: 251ms
memory: 3808kb
input:
91 49 27 -66 89 -21 -22 35 78 -64 41 -19 93 87 -92 72 -32 -67 -48 28 -6 -50 20 78 -33 90 41 75 -51 43 89 9 -89 -35 -73 88 13 13 82 82 -40 72 -21 -75 36 15 79 -66 -21 -99 -49 -33 60 78 -27 -86 -64 61 66 96 -77 37 -71 72 -35 -9 38 86 -68 51 65 15 -16 -64 -25 -72 23 81 -20 60 60 -52 -99 19 24 83 27 -11...
output:
0.000000000000016 0.000000000000000 391.127206880941571 0.000000000000000 28313.212264150944975 0.000000000000012 11477.662564206882962 4368.006677005975689 14406.483590595558780 5814.427201070789124 0.000000000000000 50112.716889796356554 0.000000000000000 0.000000000000000 0.000000000000000 0.0000...
result:
ok 100000 numbers
Test #5:
score: 0
Accepted
time: 249ms
memory: 3780kb
input:
-67 241 62 -271 -19 -199 364 487 343 293 433 -343 346 -321 78 -119 68 -487 -319 -45 -165 465 142 491 -310 476 -388 419 409 -124 167 -448 362 233 341 -119 9 -422 290 202 321 -217 310 216 286 172 10 -220 77 107 -282 352 -438 -26 171 81 111 -192 70 -132 376 -361 246 -371 354 -77 -400 -224 457 118 -387 ...
output:
0.000000000000000 417528.646965721738525 0.000000000000000 0.000000000000000 49064.274495412828401 5211742.513100332580507 3370766.246515172068030 0.000000000000000 0.000000000000000 84.405133541449885 165311.117708426550962 0.000000000000000 0.000000000000000 0.000000000000000 52736.152560963157157...
result:
ok 100000 numbers