QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#533166#7521. Find the GaplongyinCompile Error//C++142.2kb2024-08-25 18:00:412024-08-25 18:00:41

Judging History

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

  • [2024-08-25 18:00:41]
  • 评测
  • [2024-08-25 18:00:41]
  • 提交

answer

#include <bits/stdc++.h>
#define endl "\n"
using namespace std;

using ll = long long;
const double INF = 1e9;
const int N = 55;

struct Point {
    ll x, y, z;
} points[N];

struct Vector {
    ll x, y, z;
};

struct Plane {
    ll a, b, c, d;
};

ll toLeftTest(Point p, Point q, Point s) {
    return p.x * q.y + q.x * s.y + s.x * p.y - p.x * s.y - q.x * p.y - s.x * q.y;
}

Plane crossProduct(const Vector& p1, const Vector& p2, const Point& p) {
    Plane res;
    res.a = p1.y * p2.z - p1.z * p2.y;
    res.b = p1.z * p2.x - p1.x * p2.z;
    res.c = p1.x * p2.y - p1.y * p2.x;
    res.d = -(res.a * p.x + res.b * p.y + res.c * p.z);
    return res;
}

double distance(Point& p, Plane& pla) {
    return (1.0 * pla.a * p.x + pla.b * p.y + pla.c * p.z + pla.d) / sqrt(pla.a * pla.a + pla.b * pla.b + pla.c * pla.c);
}

int main() {
    ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);

    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> points[i].x >> points[i].y >> points[i].z;
    }

    if (n <= 3) {
        cout << 0 << endl;
        return 0;
    }

    double ans = INF;
    for (int i = 1; i <= n; i++) {
        Point p = points[i];
        for (int j = i + 1; j <= n; j++) {
            Point q = points[j];
            for (int k = j + 1; k <= n; k++) {
                Point s = points[k];
                if (toLeftTest(p, q, s) == 0) 
                    continue;
                Vector p1 = {p.x - q.x, p.y - q.y, p.z - q.z};
                Vector p2 = {s.x - q.x, s.y - q.y, s.z - q.z};
                Plane pla = crossProduct(p1, p2, q);

                int cnt1 = 0, cnt2 = 0;
                double cur = 0;
                for (int l = 1; l <= n; l++) {
                    double d = distance(points[l], pla);
                    if (d > 0)
                        cnt1++;
                    if (d < 0)
                        cnt2++;
                    cur = max(cur, abs(d));
                }
                if (!(cnt1 && cnt2)) {
                    ans = min(ans, cur);
                }
            }
        }
    }

    cout << fixed << setprecision(20) << ans == INF ? 0 : ans << endl;

    return 0;
}

Details

answer.code: In function ‘int main()’:
answer.code:82:46: error: no match for ‘operator==’ (operand types are ‘std::basic_ostream<char>::__ostream_type’ {aka ‘std::basic_ostream<char>’} and ‘const double’)
   82 |     cout << fixed << setprecision(20) << ans == INF ? 0 : ans << endl;
      |     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^~ ~~~
      |                                       |         |
      |                                       |         const double
      |                                       std::basic_ostream<char>::__ostream_type {aka std::basic_ostream<char>}
answer.code:82:46: note: candidate: ‘operator==(int, double)’ (built-in)
   82 |     cout << fixed << setprecision(20) << ans == INF ? 0 : ans << endl;
      |     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~
answer.code:82:46: note:   no known conversion for argument 1 from ‘std::basic_ostream<char>::__ostream_type’ {aka ‘std::basic_ostream<char>’} to ‘int’
In file included from /usr/include/c++/13/regex:68,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:181,
                 from answer.code:1:
/usr/include/c++/13/bits/regex.h:1103:5: note: candidate: ‘template<class _BiIter> bool std::__cxx11::operator==(const sub_match<_BiIter>&, const sub_match<_BiIter>&)’
 1103 |     operator==(const sub_match<_BiIter>& __lhs, const sub_match<_BiIter>& __rhs)
      |     ^~~~~~~~
/usr/include/c++/13/bits/regex.h:1103:5: note:   template argument deduction/substitution failed:
answer.code:82:49: note:   ‘std::basic_ostream<char>::__ostream_type’ {aka ‘std::basic_ostream<char>’} is not derived from ‘const std::__cxx11::sub_match<_BiIter>’
   82 |     cout << fixed << setprecision(20) << ans == INF ? 0 : ans << endl;
      |                                                 ^~~
/usr/include/c++/13/bits/regex.h:1199:5: note: candidate: ‘template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator==(__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&, const sub_match<_BiIter>&)’
 1199 |     operator==(const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __lhs,
      |     ^~~~~~~~
/usr/include/c++/13/bits/regex.h:1199:5: note:   template argument deduction/substitution failed:
answer.code:82:49: note:   ‘std::basic_ostream<char>::__ostream_type’ {aka ‘std::basic_ostream<char>’} is not derived from ‘std::__cxx11::__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>’
   82 |     cout << fixed << setprecision(20) << ans == INF ? 0 : ans << endl;
      |                                                 ^~~
/usr/include/c++/13/bits/regex.h:1274:5: note: candidate: ‘template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator==(const sub_match<_BiIter>&, __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&)’
 1274 |     operator==(const sub_match<_Bi_iter>& __lhs,
      |     ^~~~~~~~
/usr/include/c++/13/bits/regex.h:1274:5: note:   template argument deduction/substitution failed:
answer.code:82:49: note:   ‘std::basic_ostream<char>::__ostream_type’ {aka ‘std::basic_ostream<char>’} is not derived from ‘const std::__cxx11::sub_match<_BiIter>’
   82 |     cout << fixed << setprecision(20) << ans == INF ? 0 : ans << endl;
      |                                                 ^~~
/usr/include/c++/13/bits/regex.h:1366:5: note: candidate: ‘template<class _Bi_iter> bool std::__cxx11::operator==(const typename std::iterator_traits<_Iter>::value_type*, const sub_match<_BiIter>&)’
 1366 |     operator==(typename iterator_traits<_Bi_iter>::value_type const* __lhs,
      |     ^~~~~~~~
/usr/include/c++/13/bits/regex.h:1366:5: note:   template argument deduction/substitution failed:
answer.code:82:49: note:   mismatched types ‘const std::__cxx11::sub_match<_BiIter>’ and ‘const double’
   82 |     cout << fixed << setprecision(20) << ans == INF ? 0 : ans << endl;
      |                                                 ^~~
/usr/include/c++/13/bits/regex.h:1441:5: note: candidate: ‘template<class _Bi_iter> bool std::__cxx11::operator==(const sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type*)’
 1441 |     operator==(const sub_match<_Bi_iter>& __lhs,
      |     ^~~~~~~~
/usr/include/c++/13/bits/regex.h:1441:5: note:   template argument deduction/substitution failed:
answer.code:82:49: note:   ‘std::basic_ostream<char>::__ostream_type’ {aka ‘std::basic_ostream<char>’} is not derived from ‘const std::__cxx11::sub_match<_BiIter>’
   82 |     cout << fixed << setprecision(20) << ans == INF ? 0 : ans << endl;
      |                                                 ^~~
/usr/include/c++/13/bits/regex.h:1534:5: note: candidate: ‘template<class _Bi_iter> bool std::__cxx11::operator==(const typename std::iterator_traits<_Iter>::value_type&, const sub_match<_BiIter>&)’
 1534 |     operator==(typename iterator_traits<_Bi_iter>::value_type const& __lhs,
      |     ^~~~~~~~
/usr/include/c++/13/bits/regex.h:1534:5: note:   template argument deduction/substitution fail...