QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#773136#9316. Boxeshos_lyric#WA 244ms12932kbC++144.4kb2024-11-23 01:37:042024-11-23 01:37:05

Judging History

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

  • [2024-11-23 01:37:05]
  • 评测
  • 测评结果:WA
  • 用时:244ms
  • 内存:12932kb
  • [2024-11-23 01:37:04]
  • 提交

answer

#include <cassert>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

using Int = long long;

template <class T1, class T2> ostream &operator<<(ostream &os, const pair<T1, T2> &a) { return os << "(" << a.first << ", " << a.second << ")"; };
template <class T> ostream &operator<<(ostream &os, const vector<T> &as) { const int sz = as.size(); os << "["; for (int i = 0; i < sz; ++i) { if (i >= 256) { os << ", ..."; break; } if (i > 0) { os << ", "; } os << as[i]; } return os << "]"; }
template <class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cerr << *i << " "; cerr << endl; }
template <class T> bool chmin(T &t, const T &f) { if (t > f) { t = f; return true; } return false; }
template <class T> bool chmax(T &t, const T &f) { if (t < f) { t = f; return true; } return false; }
#define COLOR(s) ("\x1b[" s "m")


inline int sig(Int r) { return (r < 0) ? -1 : (r > 0) ? +1 : 0; }
inline Int sq(Int r) { return r * r; }

struct PT {
  Int x, y, z;
  PT() {}
  PT(Int x_, Int y_, Int z_) : x(x_), y(y_), z(z_) {}
  PT operator+(const PT &a) const { return PT(x + a.x, y + a.y, z + a.z); }
  PT operator-(const PT &a) const { return PT(x - a.x, y - a.y, z - a.z); }
  PT operator+() const { return PT(+x, +y, +z); }
  PT operator-() const { return PT(-x, -y, -z); }
  PT operator*(const Int &k) const { return PT(x * k, y * k, z * k); }
  PT operator/(const Int &k) const { return PT(x / k, y / k, z / k); }
  friend PT operator*(const Int &k, const PT &a) { return PT(k * a.x, k * a.y, k * a.z); }
  PT &operator+=(const PT &a) { x += a.x; y += a.y; z += a.z; return *this; }
  PT &operator-=(const PT &a) { x -= a.x; y -= a.y; z -= a.z; return *this; }
  PT &operator*=(const Int &k) { x *= k; y *= k; z *= k; return *this; }
  PT &operator/=(const Int &k) { x /= k; y /= k; z /= k; return *this; }
  Int abs2() const { return x * x + y * y + z * z; }
  Int dot(const PT &a) const { return x * a.x + y * a.y + z * a.z; }
  PT cross(const PT a) const { return PT(y * a.z - z * a.y, z * a.x - x * a.z, x * a.y - y * a.x); }
  friend ostream &operator<<(ostream &os, const PT &a) { os << "(" << a.x << ", " << a.y << ", " << a.z << ")"; return os; }
};
PT tri(const PT &a, const PT &b, const PT &c) { return (b - a).cross(c - a); }
Int tet(const PT &a, const PT &b, const PT &c, const PT &d) { return (b - a).cross(c - a).dot(d - a); }


// !!!no 4 points coplanar!!!
vector<vector<int>> convexHull(const vector<PT> &ps) {
  const int n = ps.size();
  // vector<vector<bool>> s(n, vector<bool>(n, false));
  static bool s[3010][3010];
  vector<vector<int>> crt{{0, 1, 2}, {0, 2, 1}};
  for (int i = 3; i < n; ++i) {
    for (const auto &f : crt) s[f[1]][f[2]] = s[f[2]][f[0]] = s[f[0]][f[1]] = (tet(ps[f[0]], ps[f[1]], ps[f[2]], ps[i]) < 0);
    vector<vector<int>> nxt;
    for (const auto &f : crt) {
      if (s[f[1]][f[2]]) {
        nxt.push_back(f);
      } else {
        if (s[f[2]][f[1]]) nxt.push_back({f[1], f[2], i});
        if (s[f[0]][f[2]]) nxt.push_back({f[2], f[0], i});
        if (s[f[1]][f[0]]) nxt.push_back({f[0], f[1], i});
      }
    }
    crt.swap(nxt);
  }
  return crt;
}


int N;
vector<PT> P;

int main() {
  for (int numCases; ~scanf("%d", &numCases); ) { for (int caseId = 1; caseId <= numCases; ++caseId) {
    scanf("%d", &N);
    P.resize(N);
    for (int u = 0; u < N; ++u) {
      scanf("%lld%lld%lld", &P[u].x, &P[u].y, &P[u].z);
    }
    
    Int ans = 0;
    for (auto ps = P; ; ) {
      const int n = ps.size();
      if (n < 4) break;
      const auto uss = convexHull(ps);
      vector<int> used(n, 0);
      Int vol = 0;
      for (const auto &us : uss) {
        vol += tet(PT(0, 0, 0), ps[us[0]], ps[us[1]], ps[us[2]]);
        for (const int u : us) used[u] = 1;
      }
// cerr<<ps<<": "<<vol<<" "<<uss<<endl;
      ans += vol;
      vector<PT> qs;
      for (int u = 0; u < n; ++u) if (!used[u]) qs.push_back(ps[u]);
      ps.swap(qs);
    }
    printf("%lld\n", ans);
  }
#ifndef LOCAL
  break;
#endif
  }
  return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3820kb

input:

2
4
0 0 1
0 0 2
0 1 1
1 1 1
10
2 6 3
2 9 0
2 1 0
3 7 3
0 5 6
10 9 2
4 4 2
8 5 2
4 6 9
6 7 5

output:

1
943

result:

ok 2 lines

Test #2:

score: 0
Accepted
time: 9ms
memory: 4124kb

input:

30
100
214848 13593 883915
404922 704679 762266
19696 348707 172137
204169 674312 980107
159743 683657 537795
913278 244484 331997
342255 150373 745862
822992 993127 812010
78019 523301 874868
508779 130959 577626
506563 15210 31018
302821 671498 135922
379735 258803 474373
387144 676958 499943
9009...

output:

8466306477510658674
7272556711339503943
7635348833914404146
8107228712222480162
8154398837331856360
7551703717471512369
8340343101157128252
7911868248459799324
7911957494280349996
8295429352750849603
8170150524727285883
7448641514858636645
8373196774630538132
7404986332777191754
7496214926512003280
...

result:

ok 30 lines

Test #3:

score: 0
Accepted
time: 2ms
memory: 3816kb

input:

300
10
284000 364959 249145
243447 261451 165064
884086 450907 263262
986606 115922 516435
550174 625062 491782
992985 764800 854837
992741 919628 758329
114851 373304 743149
236804 572126 522753
694056 863964 768484
10
328584 59621 865079
133943 928163 534857
746608 698892 195503
199343 568337 4820...

output:

803077918387863438
484728351097401010
1106436691630702280
544591678232219117
1068791025597242587
930320279051363466
977769839732812040
699051820151945692
1140525392772278038
1116781785107680980
844917700022644714
672066651386061967
638048751063849731
1258576451479348061
476673417837522259
8473170752...

result:

ok 300 lines

Test #4:

score: -100
Wrong Answer
time: 244ms
memory: 12932kb

input:

1
3000
413652 522034 362874
161444 14592 423619
276585 592939 402025
969689 188554 136993
462321 11911 652603
155677 401331 635931
339965 202216 204346
992462 357822 565008
886658 168024 940016
767608 638795 810396
137017 720592 591380
131999 195424 726856
127795 754489 391676
201652 890036 283312
2...

output:

4933347942154243019

result:

wrong answer 1st lines differ - expected: '60273580163282897867', found: '4933347942154243019'