QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#566943 | #9316. Boxes | shiqiaqiaya | Compile Error | / | / | C++20 | 3.9kb | 2024-09-16 04:02:53 | 2024-09-16 04:02:53 |
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;
set<array<int, 2>> edge;
for (auto & x : res) {
int t = x.above(q[i]);
auto & [a, b, c] = x.v;
if (x.above(q[i])) {
edge.emplace(array<int, 2>{a, b});
edge.emplace(array<int, 2>{b, c});
edge.emplace(array<int, 2>{c, a});
} else {
nf.emplace_back(a, b, c);
}
}
for (auto & [x, y] : edge) {
if (edge.count({y, x})) continue;
nf.emplace_back(x, y, i);
}
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];
}
__int128 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(a, ta);
}
auto out = [&](auto && self, __int128 t) {
if (t == 0) return;
self(self, t / 10);
cout << (int)(t % 10);
};
out(out, ans);
cout << "\n";
}
signed main() {
cin.tie(0) -> sync_with_stdio(0);
cout << fixed << setprecision(3);
int t = 1;
cin >> t;
while (t--) {
QAQ();
}
}
詳細信息
In file included from /usr/include/c++/13/ext/alloc_traits.h:34, from /usr/include/c++/13/bits/basic_string.h:39, from /usr/include/c++/13/string:54, from /usr/include/c++/13/bitset:52, from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:52, from answer.code:1: /usr/include/c++/13/bits/alloc_traits.h: In instantiation of ‘static constexpr void std::allocator_traits<std::allocator<_CharT> >::construct(allocator_type&, _Up*, _Args&& ...) [with _Up = face; _Args = {long long int&, long long int&, long long int&}; _Tp = face; allocator_type = std::allocator<face>]’: /usr/include/c++/13/bits/vector.tcc:117:30: required from ‘constexpr std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::emplace_back(_Args&& ...) [with _Args = {long long int&, long long int&, long long int&}; _Tp = face; _Alloc = std::allocator<face>; reference = face&]’ answer.code:61:32: required from here /usr/include/c++/13/bits/alloc_traits.h:539:28: error: no matching function for call to ‘construct_at(face*&, long long int&, long long int&, long long int&)’ 539 | std::construct_at(__p, std::forward<_Args>(__args)...); | ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/13/bits/stl_iterator.h:85, from /usr/include/c++/13/bits/stl_algobase.h:67, from /usr/include/c++/13/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:51: /usr/include/c++/13/bits/stl_construct.h:94:5: note: candidate: ‘template<class _Tp, class ... _Args> constexpr decltype (::new(void*(0)) _Tp) std::construct_at(_Tp*, _Args&& ...)’ 94 | construct_at(_Tp* __location, _Args&&... __args) | ^~~~~~~~~~~~ /usr/include/c++/13/bits/stl_construct.h:94:5: note: template argument deduction/substitution failed: /usr/include/c++/13/bits/stl_construct.h: In substitution of ‘template<class _Tp, class ... _Args> constexpr decltype (::new(void*(0)) _Tp) std::construct_at(_Tp*, _Args&& ...) [with _Tp = face; _Args = {long long int&, long long int&, long long int&}]’: /usr/include/c++/13/bits/alloc_traits.h:539:21: required from ‘static constexpr void std::allocator_traits<std::allocator<_CharT> >::construct(allocator_type&, _Up*, _Args&& ...) [with _Up = face; _Args = {long long int&, long long int&, long long int&}; _Tp = face; allocator_type = std::allocator<face>]’ /usr/include/c++/13/bits/vector.tcc:117:30: required from ‘constexpr std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::emplace_back(_Args&& ...) [with _Args = {long long int&, long long int&, long long int&}; _Tp = face; _Alloc = std::allocator<face>; reference = face&]’ answer.code:61:32: required from here /usr/include/c++/13/bits/stl_construct.h:96:17: error: could not convert ‘std::declval<long long int&>()’ from ‘long long int’ to ‘std::array<long long int, 3>’ 96 | -> decltype(::new((void*)0) _Tp(std::declval<_Args>()...)) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | | long long int /usr/include/c++/13/bits/alloc_traits.h: In instantiation of ‘static constexpr void std::allocator_traits<std::allocator<_CharT> >::construct(allocator_type&, _Up*, _Args&& ...) [with _Up = face; _Args = {const long long int&, const long long int&, long long int&}; _Tp = face; allocator_type = std::allocator<face>]’: /usr/include/c++/13/bits/vector.tcc:117:30: required from ‘constexpr std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::emplace_back(_Args&& ...) [with _Args = {const long long int&, const long long int&, long long int&}; _Tp = face; _Alloc = std::allocator<face>; reference = face&]’ answer.code:66:28: required from here /usr/include/c++/13/bits/alloc_traits.h:539:28: error: no matching function for call to ‘construct_at(face*&, const long long int&, const long long int&, long long int&)’ 539 | std::construct_at(__p, std::forward<_Args>(__args)...); | ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/13/bits/stl_construct.h:94:5: note: candidate: ‘template<class _Tp, class ... _Args> constexpr decltype (::new(void*(0)) _Tp) std::construct_at(_Tp*, _Args&& ...)’ 94 | construct_at(_Tp* __location, _Args&&... __args) | ^~~~~~~~~~~~ /usr/include/c++/13/bits/stl_construct.h:94:5: note: template argument deduction/substitution failed: /usr/include/c++/13/bits/stl_construct.h: In substitution of ‘template<class _Tp, class ... _Args> constexpr decltype (::new(void*(0)) _Tp) std::construct_at(_Tp*, _Args&& ...) [with _Tp = face; _Args = {const long long int&, const long long int&, long long int&}]’: /usr/include/c++/13/bits/alloc_traits.h:539:21: required from ‘static constexpr void std::allocator_traits<std::allocator<_CharT> >::construct(allocator_type&, _Up*, _Args&& ...) [with _Up = face; _Args ...