QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#577181 | #8082. Minimum Euclidean Distance | xinhuo2005 | Compile Error | / | / | C++17 | 2.5kb | 2024-09-20 08:51:33 | 2024-09-20 08:51:35 |
Judging History
answer
#include<bits/stdc++.h>
using ll = long long;
const int mod = 998244353;
#define double long double
#define pdd std::pair<double, double>
#define x first
#define y second
const double PI = acos(-1);
std::pair<double, double> operator- (const std::pair<double, double> a, const std::pair<double, double> b) {
return {a.first - b.first, a.second - b.second};
}
void solve() {
int n, q;
std::cin >> n >> q;
std::vector<std::pair<double, double>> A(n);
for (int i = 0; i < n; i++) {
std::cin >> A[i].first >> A[i].second;
}
auto dis = [&](pdd a) {
return sqrt(a.x * a.x + a.y * a.y);
};
auto Dot = [&](pdd a, pdd b) {
return (a.x * b.x + a.y * b.y);
};
auto Cro = [&](pdd a, pdd b) {
return a.x * b.y - a.y * b.x;
};
auto cmp = [&](double xx) {
if (fabs(xx - 1e-8) <= 0.0) return 0.0;
return (xx < 0.0 ? -1.0 : 1.0);
};
auto isCon = [&](double xl, double yl, double xr, double yr) {
double x = (xl + xr) / 2, y = (yl + yr) / 2;
pdd o = {x, y};
std::vector<int> ok(n);
for (int i = 0; i < n; i++) {
double x = Cro(A[(i + 1) % n] - A[i], o - A[i]);
if (cmp(x) == 0) ok[i] = 0;
if (cmp(x) < 0) ok[i] = -1;
else ok[i] = 1;
}
int mn = *std::min_element(ok.begin(), ok.end());
int mx = *std::max_element(ok.begin(), ok.end());
if (mn + mx != 0) return true;
else return false;
};
auto dis_ps = [&](pdd a, pdd b, pdd p) {
if ((cmp(Dot(p - a, a - b)) >= 0) ^ (cmp(Dot(p - b, a - b)) >= 0)) {
return fabs(Cro(a - p, b - p)) / dis(a - b);
}
else {
return std::min(dis(p - a), dis(p - b));
}
};
while (q--) {
double xl, yl, xr, yr;
std::cin >> xl >> yl >> xr >> yr;
double ans = dis({xl - xr, yl - yr}) / 2;
ans = ans * ans / 2.0;
pdd o = {(xl + xr) / 2, (yl + yr) / 2};
if (!isCon(xl, yl, xr, yr)) {
double mn = 1e9;
for (int i = 0; i < n; i++) {
mn = std::min(mn, dis_ps(A[i], A[(i + 1) % n], o));
}
ans += mn * mn;
}
std::cout << std::fixed << std::setprecision(10);
std::cout << ans << "\n";
}
}
signed main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
int t = 1;
// std::cin >> t;
while (t--) {
solve();
}
return 0;
}
Details
answer.code: In function ‘void solve()’: answer.code:70:30: error: no matching function for call to ‘min(long double&, double)’ 70 | mn = std::min(mn, dis_ps(A[i], A[(i + 1) % n], o)); | ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/13/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:51, from answer.code:1: /usr/include/c++/13/bits/stl_algobase.h:233:5: note: candidate: ‘template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)’ 233 | min(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/13/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed: answer.code:70:30: note: deduced conflicting types for parameter ‘const _Tp’ (‘long double’ and ‘double’) 70 | mn = std::min(mn, dis_ps(A[i], A[(i + 1) % n], o)); | ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/13/bits/stl_algobase.h:281:5: note: candidate: ‘template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)’ 281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/13/bits/stl_algobase.h:281:5: note: template argument deduction/substitution failed: answer.code:70:30: note: deduced conflicting types for parameter ‘const _Tp’ (‘long double’ and ‘double’) 70 | mn = std::min(mn, dis_ps(A[i], A[(i + 1) % n], o)); | ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/13/algorithm:61: /usr/include/c++/13/bits/stl_algo.h:5775:5: note: candidate: ‘template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)’ 5775 | min(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/13/bits/stl_algo.h:5775:5: note: template argument deduction/substitution failed: answer.code:70:30: note: mismatched types ‘std::initializer_list<_Tp>’ and ‘long double’ 70 | mn = std::min(mn, dis_ps(A[i], A[(i + 1) % n], o)); | ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/13/bits/stl_algo.h:5785:5: note: candidate: ‘template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)’ 5785 | min(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/13/bits/stl_algo.h:5785:5: note: template argument deduction/substitution failed: answer.code:70:30: note: mismatched types ‘std::initializer_list<_Tp>’ and ‘long double’ 70 | mn = std::min(mn, dis_ps(A[i], A[(i + 1) % n], o)); | ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~