QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#665590#2838. 2D Geometryticking_away#Compile Error//C++202.3kb2024-10-22 14:16:532024-10-22 14:16:59

Judging History

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

  • [2024-10-22 14:16:59]
  • 评测
  • [2024-10-22 14:16:53]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
using ui = unsigned int;
using ull = unsigned long long;
using ll = long long;
#define endl '\n'
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int maxn = 2e5 + 10;
const int mod = 1000000007;
#define inl inline
#define fr(i, a, b) for (int i = a; i <= b; i++)
#define ford(i, a, b) for (int i = a; i >= b; i--)
#define forall(i, a) for (auto &i : a)

/**
   ____         ___ _____
  / ___| _   _ / _ \___ /
  \___ \| | | | | | ||_ \
   ___) | |_| | |_| |__) |
  |____/ \__, |\___/____/
         |___/
*/
istream &operator>>(istream &in, vector<int> &v)
{
    for (auto &i : v)
        in >> i;
    return in;
}
ostream &operator<<(ostream &out, vector<int> &v)
{
    for (auto &i : v)
        out << i << " ";
    return out;
}
bool _output = 0;

#define int ll
struct P
{
    int x, y;
    P(int x, int y) : x(x), y(y) {}
    P operator-(P b) { return P(x - b.x, y - b.y); }
};
int det(P a, P b)
{
    return a.x * b.y - a.y * b.x;
}

void solve(int n)
{
    vector<P> ps(n);
    for (int i = 0; i < n; i++)
    {
        int x, y;
        cin >> x >> y;
        ps[i] = P(x, y);
    }
    auto rand = [&]()
    {
        mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
        return rng() % n;
    };
    int cnt = 100;
    int ans = n % 3;
    if (n <= 2)
    {
        cout << n << endl;
        return;
    }
    // cout<<"! "<<endl;
    while (cnt--)
    {
        int x = rand(), y = rand();
        // cout<<x<<" "<<y<<endl;
        if (x == y)
        {
            // cnt++;
            continue;
        }
        int t = 2;
        for (int i = 0; i < n; i++)
        {
            if (i == x || i == y)
                continue;
            auto ta = ps[x], tb = ps[y], tc = ps[i];
            if (det(tb - ta, tc - ta) == 0)
            {
                t++;
            }
        }
        // cout << x << " " << y << " " << t << endl;
        int res = max(0ll, 3 * t - n * 2);
        ans = max(ans, res);
    }
    cout << ans << endl;
}
signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int _ = 1;
    if (_output)
        cin >> _;
    int n;
    while (cin >> n)
        solve(n);
    return 0;
}

Details

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,
                 from answer.code:1:
/usr/include/c++/13/bits/stl_construct.h: In instantiation of ‘constexpr void std::_Construct(_Tp*, _Args&& ...) [with _Tp = P; _Args = {}]’:
/usr/include/c++/13/bits/stl_uninitialized.h:643:18:   required from ‘static constexpr _ForwardIterator std::__uninitialized_default_n_1<_TrivialValueType>::__uninit_default_n(_ForwardIterator, _Size) [with _ForwardIterator = P*; _Size = long unsigned int; bool _TrivialValueType = false]’
/usr/include/c++/13/bits/stl_uninitialized.h:706:20:   required from ‘constexpr _ForwardIterator std::__uninitialized_default_n(_ForwardIterator, _Size) [with _ForwardIterator = P*; _Size = long unsigned int]’
/usr/include/c++/13/bits/stl_uninitialized.h:773:44:   required from ‘constexpr _ForwardIterator std::__uninitialized_default_n_a(_ForwardIterator, _Size, allocator<_Tp>&) [with _ForwardIterator = P*; _Size = long unsigned int; _Tp = P]’
/usr/include/c++/13/bits/stl_vector.h:1715:36:   required from ‘constexpr void std::vector<_Tp, _Alloc>::_M_default_initialize(size_type) [with _Tp = P; _Alloc = std::allocator<P>; size_type = long unsigned int]’
/usr/include/c++/13/bits/stl_vector.h:555:9:   required from ‘constexpr std::vector<_Tp, _Alloc>::vector(size_type, const allocator_type&) [with _Tp = P; _Alloc = std::allocator<P>; size_type = long unsigned int; allocator_type = std::allocator<P>]’
answer.code:52:19:   required from here
/usr/include/c++/13/bits/stl_construct.h:115:28: error: no matching function for call to ‘construct_at(P*&)’
  115 |           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 = P; _Args = {}]’:
/usr/include/c++/13/bits/stl_construct.h:115:21:   required from ‘constexpr void std::_Construct(_Tp*, _Args&& ...) [with _Tp = P; _Args = {}]’
/usr/include/c++/13/bits/stl_uninitialized.h:643:18:   required from ‘static constexpr _ForwardIterator std::__uninitialized_default_n_1<_TrivialValueType>::__uninit_default_n(_ForwardIterator, _Size) [with _ForwardIterator = P*; _Size = long unsigned int; bool _TrivialValueType = false]’
/usr/include/c++/13/bits/stl_uninitialized.h:706:20:   required from ‘constexpr _ForwardIterator std::__uninitialized_default_n(_ForwardIterator, _Size) [with _ForwardIterator = P*; _Size = long unsigned int]’
/usr/include/c++/13/bits/stl_uninitialized.h:773:44:   required from ‘constexpr _ForwardIterator std::__uninitialized_default_n_a(_ForwardIterator, _Size, allocator<_Tp>&) [with _ForwardIterator = P*; _Size = long unsigned int; _Tp = P]’
/usr/include/c++/13/bits/stl_vector.h:1715:36:   required from ‘constexpr void std::vector<_Tp, _Alloc>::_M_default_initialize(size_type) [with _Tp = P; _Alloc = std::allocator<P>; size_type = long unsigned int]’
/usr/include/c++/13/bits/stl_vector.h:555:9:   required from ‘constexpr std::vector<_Tp, _Alloc>::vector(size_type, const allocator_type&) [with _Tp = P; _Alloc = std::allocator<P>; size_type = long unsigned int; allocator_type = std::allocator<P>]’
answer.code:52:19:   required from here
/usr/include/c++/13/bits/stl_construct.h:96:17: error: no matching function for call to ‘P::P()’
   96 |     -> decltype(::new((void*)0) _Tp(std::declval<_Args>()...))
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
answer.code:42:5: note: candidate: ‘P::P(ll, ll)’
   42 |     P(int x, int y) : x(x), y(y) {}
      |     ^
answer.code:42:5: note:   candidate expects 2 arguments, 0 provided
answer.code:39:8: note: candidate: ‘constexpr P::P(const P&)’
   39 | struct P
      |        ^
answer.code:39:8: note:   candidate expects 1 argument, 0 provided
answer.code:39:8: note: candidate: ‘constexpr P::P(P&&)’
answer.code:39:8: note:   candidate expects 1 argument, 0 provided
/usr/include/c++/13/bits/stl_construct.h: In instantiation of ‘constexpr void std::_Construct(_Tp*, _Args&& ...) [with _Tp = P; _Args = {}]’:
/usr/include/c++/13/bits/stl_uninitialized.h:643:18:   required from ‘static constexpr _ForwardIterator std::__uninitialized_default_n_1<_TrivialValueType>::__uninit_default_n(_ForwardIterator, _Size) [with _ForwardIterator = P*; _Size = long unsigned in...