QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#566929 | #9316. Boxes | shiqiaqiaya | WA | 143ms | 73876kb | C++20 | 3.7kb | 2024-09-16 03:42:32 | 2024-09-16 03:42:33 |
Judging History
answer
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // 包含 tree、gp_hash_table、cc_hash_table
#include <ext/pb_ds/priority_queue.hpp> // 引入后使用 STL 的堆需要 std::
#include <ext/rope>
using namespace __gnu_pbds;
using namespace __gnu_cxx;
using namespace std;
template<class key, class val = null_type, class cmp = less<>>
using rb_tree = tree<key, val, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class key, class cmp = less<>>
using pairing_heap = __gnu_pbds::priority_queue<key, cmp>;
typedef long long ll;
#define int long long
mt19937_64 rd(time(0));
using type = int;
struct point : array<type, 3> {
point operator * (const point & t) const { return {at(1) * t[2] - at(2) * t[1], at(2) * t[0] - at(0) * t[2], at(0) * t[1] - at(1) * t[0]}; }
type operator / (const point & t) const { return at(0) * t[0] + at(1) * t[1] + at(2) * t[2]; }
point & operator += (const point & t) { return at(0) += t[0], at(1) += t[1], at(2) += t[2], *this; }
point operator + (const point & t) const { return point(*this) += t; }
point & operator -= (const point & t) { return at(0) -= t[0], at(1) -= t[1], at(2) -= t[2], *this; }
point operator - (const point & t) const { return point(*this) -= t; }
point & operator *= (const type & t) { return at(0) *= t, at(1) *= t, at(2) *= t, *this; }
point operator * (const type & t) const { return point(*this) *= t; }
point & operator /= (const type & t) { return at(0) /= t, at(1) /= t, at(2) /= t, *this; }
point operator / (const type & t) const { return point(*this) /= t; }
void shake(double eps = 1e-10) {
for (auto & t : *this) {
t += ((double)rand() / RAND_MAX - 0.5) * eps;
}
}
};
struct face {
array<int, 3> v;
point p, norm;
bool above(const point & t) {
return (t - p) / norm > 0;
}
};
static vector<face> hull(vector<point> & q, vector<face> res = {}) {
vector g(q.size(), vector<int>(q.size()));
res.emplace_back(face{0, 1, 2, q[0], (q[1] - q[0]) * (q[2] - q[0])});
res.emplace_back(face{2, 1, 0, q[2], (q[1] - q[2]) * (q[0] - q[2])});
for (int i = 3; i < q.size(); i++) {
vector<face> nf;
for (auto & x : res) {
int t = x.above(q[i]);
if (!t) nf.emplace_back(x);
for (int k = 0; k < 3; k++) {
int a = x.v[k], b = x.v[(k + 1) % 3];
g[a][b] = t;
}
}
for (auto & x : res) {
for (int k = 0; k < 3; k++) {
int a = x.v[k], b = x.v[(k + 1) % 3];
if (g[a][b] && !g[b][a]) {
nf.emplace_back(face{a, b, i, q[a], (q[b] - q[a]) * (q[i] - q[a])});
}
}
}
swap(res, nf);
}
return res;
}
void QAQ() {
int n;
cin >> n;
vector<point> a(n);
for (int i = 0; i < n; i++) {
cin >> a[i][0] >> a[i][1] >> a[i][2];
}
int ans = 0;
while (a.size() > 3) {
shuffle(a.begin(), a.end(), rd);
vector<int> vis(a.size());
auto res = hull(a);
for (auto & x : res) {
(ans += a[x.v[0]] * a[x.v[1]] / a[x.v[2]]);
for (auto & idx : x.v) {
vis[idx] = 1;
}
}
vector<point> ta;
for (int i = 0; i < a.size(); i++) {
if (!vis[i]) {
ta.push_back(a[i]);
}
}
swap(ta, a);
}
cout << ans << "\n";
}
signed main() {
cin.tie(0) -> sync_with_stdio(0);
cout << fixed << setprecision(3);
int t = 1;
cin >> t;
while (t--) {
QAQ();
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3708kb
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: 5ms
memory: 3900kb
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: 3660kb
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: 143ms
memory: 73876kb
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'