QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#371227 | #8505. Almost Aligned | ucup-team3215 | Compile Error | / | / | C++20 | 1.7kb | 2024-03-30 02:38:12 | 2024-03-30 02:38:14 |
Judging History
answer
#include <algorithm>
#include <array>
#include <cstdint>
#include <iostream>
using namespace std;
using point = array<int, 2>;
int64_t operator^(point a, point b) { return a[0] * (int64_t)b[1] - a[1] * (int64_t)b[0]; }
int64_t operator&(point a, point b) { return a[0] * (int64_t)b[0] + a[1] * (int64_t)b[1]; }
point operator-(point a) { return {-a[0], -a[1]}; }
point operator-(point a, point b) { return {a[0] - b[0], a[1] - b[1]}; }
vector<point> env(const vector<point>& v) {
vector<point> e;
for (auto& p: v) {
while (e.size() > 1 && (e.back() - e.end()[-2] ^ p - e.back()) >= 0) e.pop_back();
e.push_back(p);
}
return e;
}
int main() {
cin.tie(0)->sync_with_stdio(0);
int n; cin >> n;
vector<point> v[2];
v[0].resize(n), v[1].resize(n);
for (int i = 0; i < n; ++i) cin >> v[0][i][1] >> v[1][i][1] >> v[0][i][0] >> v[1][i][0];
vector<point> e[4];
for (int c: {0, 1}) {
sort(v[c].begin(), v[c].end());
e[c * 2] = env(v[c]);
for (auto& p: v[c]) p = -p;
reverse(v[c].begin(), v[c].end());
e[c * 2 + 1] = env(v[c]);
}
auto ans = 0. / 0;
int i[4]{};
while (1) {
int w = -1;
for (int j = 0; j < 4; ++j) if (i[j] + 1 < e[j].size() && (!~w || (e[j][i[j] + 1] - e[j][i[j]] ^ e[w][i[w] + 1] - e[w][i[w]]) < 0)) w = j;
auto a = e[0][i[0]] - -e[1][i[1]], b = e[2][i[2]] - -e[3][i[3]];
double t;
if (~w) { auto d = e[w][i[w] + 1] - e[w][i[w]]; ++i[w]; t = -d[1] * 1. / d[0]; }
if ((!~w || t > 0) && ans != ans) ans = a[1] * 1. * b[1];
if (!~w) break;
if (t > 0) ans = min(ans, (a[0] * t + a[1]) * (b[0] * t + b[1]));
}
cout.precision(9);
cout << fixed << ans;
}
Details
answer.code:15:1: error: ‘vector’ does not name a type 15 | vector<point> env(const vector<point>& v) { | ^~~~~~ answer.code: In function ‘int main()’: answer.code:27:3: error: ‘vector’ was not declared in this scope 27 | vector<point> v[2]; | ^~~~~~ answer.code:5:1: note: ‘std::vector’ is defined in header ‘<vector>’; did you forget to ‘#include <vector>’? 4 | #include <iostream> +++ |+#include <vector> 5 | answer.code:27:15: error: expected primary-expression before ‘>’ token 27 | vector<point> v[2]; | ^ answer.code:27:17: error: ‘v’ was not declared in this scope 27 | vector<point> v[2]; | ^ answer.code:30:15: error: expected primary-expression before ‘>’ token 30 | vector<point> e[4]; | ^ answer.code:30:17: error: ‘e’ was not declared in this scope; did you mean ‘std::numbers::e’? 30 | vector<point> e[4]; | ^ | std::numbers::e In file included from /usr/include/c++/13/bits/max_size_type.h:37, from /usr/include/c++/13/bits/ranges_base.h:39, from /usr/include/c++/13/bits/ranges_algobase.h:38, from /usr/include/c++/13/bits/ranges_algo.h:38, from /usr/include/c++/13/algorithm:63, from answer.code:1: /usr/include/c++/13/numbers:122:27: note: ‘std::numbers::e’ declared here 122 | inline constexpr double e = e_v<double>; | ^ answer.code:33:16: error: ‘env’ was not declared in this scope 33 | e[c * 2] = env(v[c]); | ^~~ answer.code:38:17: warning: division by zero [-Wdiv-by-zero] 38 | auto ans = 0. / 0; | ~~~^~~ answer.code:46:57: error: ‘b’ was not declared in this scope 46 | if ((!~w || t > 0) && ans != ans) ans = a[1] * 1. * b[1]; | ^ answer.code:48:52: error: ‘b’ was not declared in this scope 48 | if (t > 0) ans = min(ans, (a[0] * t + a[1]) * (b[0] * t + b[1])); | ^