QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#372490#2839. 3D Geometryckiseki#AC ✓101ms3880kbC++201.9kb2024-03-31 14:09:112024-03-31 14:09:12

Judging History

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

  • [2024-03-31 14:09:12]
  • 评测
  • 测评结果:AC
  • 用时:101ms
  • 内存:3880kb
  • [2024-03-31 14:09:11]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

#define all(x) begin(x), end(x)
#ifdef CKISEKI
#define safe cerr << __PRETTY_FUNCTION__ << " line " << __LINE__ << " safe\n"
#define debug(a...) debug_(#a, a)
#define orange(a...) orange_(#a, a)
void debug_(auto s, auto ...a) {
  cerr << "\e[1;32m(" << s << ") = (";
  int f = 0;
  (..., (cerr << (f++ ? ", " : "") << a));
  cerr << ")\e[0m\n";
}
#include <experimental/iterator>
void orange_(auto s, auto L, auto R) {
  cerr << "\e[1;33m[ " << s << " ] = [ ";
  using namespace experimental;
  copy(L, R, make_ostream_joiner(cerr, ", "));
  cerr << " ]\e[0m\n";
}
#else
#define safe ((void)0)
#define debug(...) safe
#define orange(...) safe
#endif

int main() {
  cin.tie(nullptr)->sync_with_stdio(false);
  int x[4], y[4], z[4];

  while (cin >> x[0] >> y[0] >> z[0]) {
    for (int j = 1; j < 4; j++)
      cin >> x[j] >> y[j] >> z[j];

    for (int j = 1; j < 4; j++) {
      x[j] -= x[0];
      y[j] -= y[0];
      z[j] -= z[0];
    }

    if (x[1] < 0) for (int j = 1; j < 4; j++) x[j] = -x[j];
    if (y[1] < 0) for (int j = 1; j < 4; j++) y[j] = -y[j];
    if (z[1] < 0) for (int j = 1; j < 4; j++) z[j] = -z[j];

    if (x[2] > x[3]) swap(x[2], x[3]);
    if (y[2] > y[3]) swap(y[2], y[3]);
    if (z[2] > z[3]) swap(z[2], z[3]);

    using llf = long double;

    llf ans = 0;
    llf a = x[1], b = y[1], c = z[1];
    for (int s = 0; s < 8; s++) {
      int X = x[ (s >> 0 & 1) + 2 ];
      int Y = y[ (s >> 1 & 1) + 2 ];
      int Z = z[ (s >> 2 & 1) + 2 ];

      if (X < 0) X = 0;
      if (Y < 0) Y = 0;
      if (Z < 0) Z = 0;

      llf D = X / a + Y / b + Z / c;
      if (D >= 1) continue;

      llf tx = (1 - D) * a;
      llf ty = (1 - D) * b;
      llf tz = (1 - D) * c;

      int coef = __builtin_parity(s) ? -1 : 1;
      ans += coef * tx * ty * tz / 6;
    }

    cout << fixed << setprecision(20);
    cout << ans << '\n';

  }
  return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3868kb

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.16666666666666666667
0.83333333333333333342
0.16666666666666666667

result:

ok 3 numbers

Test #2:

score: 0
Accepted
time: 89ms
memory: 3700kb

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.00000000000000000000
0.00000000000000000000
0.00000000000000000000
0.00000000000000000000
0.70833333333333333348
0.00000000000000000000
0.00000000000000000000
15.35565476190476190410
0.00000000000000000000
6.56250000000000000043
0.00000000000000000000
0.00000000000000000000
-0.00000000000000000000...

result:

ok 100000 numbers

Test #3:

score: 0
Accepted
time: 87ms
memory: 3848kb

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.00000000000000000000
0.00000000000000000000
0.00000000000000000000
0.00000000000000000000
0.00000000000000000000
16.25573224852071006243
0.16666666666666666656
0.00000000000000000000
26.20192307692307691520
1.44989106753812636158
0.00000000000000000000
0.00000000000000000000
0.00000000000000000000...

result:

ok 100000 numbers

Test #4:

score: 0
Accepted
time: 95ms
memory: 3828kb

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.00000000000000000899
0.00000000000000000000
391.12720688094160259585
0.00000000000000000000
28313.21226415094339401435
0.00000000000000001388
11477.66256420688603245850
4368.00667700597770437554
14406.48359059555970773658
5814.42720107079119573612
0.00000000000000000000
50112.71688979635283445191...

result:

ok 100000 numbers

Test #5:

score: 0
Accepted
time: 101ms
memory: 3880kb

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.00000000000000000000
417528.64696572187597212178
0.00000000000000000000
0.00000000000000000000
49064.27449541284400780228
5211742.51310033129720977740
3370766.24651517351571783365
0.00000000000000000000
0.00000000000000000000
84.40513354144987859945
165311.11770842652232715864
0.000000000000000000...

result:

ok 100000 numbers