QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#608664#9434. Italian Cuisinereal_sigma_team#Compile Error//C++233.3kb2024-10-04 00:43:232024-10-04 00:43:23

Judging History

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

  • [2024-10-04 00:43:23]
  • 评测
  • [2024-10-04 00:43:23]
  • 提交

answer

#include <bits/stdc++.h>
#include <immintrin.h>

using namespace std;

using ll = long long;
using ld = long double;
# define x first
# define y second
# define all(x) x.begin(), x.end()
# define rall(x) x.rbegin(), x.rend()

mt19937 mt(123);

void solve();
void init();

int32_t main() {
#ifndef LOCAL
    cin.tie(nullptr)->sync_with_stdio(false);
#endif
    init();
    cout << fixed << setprecision(10);
    int t = 1;
    cin >> t;
    while (t--) {
        solve();
    }
}

void init() {}

#define int ll

struct line {
    ll a, b, c;
    line(const pair<int, int>& _a, const pair<int, int>& _b) {
        a = _a.y - _b.y;
        b = _b.x - _a.x;
        c = -(_a.x * a + _a.y * b);
    }
    ll operator[](const pair<int, int>& _a) {
        return a * _a.x + b * _a.y + c;
    }
    ll norm() {
        return a * a + b * b;
    }
};

__int128_t dist(const pair<int, int>& a, line b) {
    return abs((__int128_t)1 * b[a] * b[a] / b.norm());
}

ll cross_prod(const pair<int, int>& a, const pair<int, int>& b) {
    return 1ll * a.x * b.y - 1ll * a.y * b.x;
}

constexpr int N = 100100;
int n;
pair<int, int> a[N];
ll s[N];
__int128_t pref[N];

__int128_t get(int l, int r) {
    if (r >= l) {
        return pref[r] - pref[l] + cross_prod(a[r], a[l]);
    }
    return pref[n] - pref[l] + pref[r] + cross_prod(a[r], a[l]);
}

ll len(const pair<int, int>& a) {
    return 1ll * a.x * a.x + 1ll * a.y * a.y;
}

pair<int, int> operator - (const pair<int, int>& a, const pair<int, int>& b) {
    return {a.x - b.x, a.y - b.y};
}

void solve() {
    cin >> n;
    pair<int, int> c;
    int r;
    cin >> c.x >> c.y >> r;
    ll ans = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i].x >> a[i].y;
    }
    pref[0] = 0;
    for (int i = 0; i < n; i++) {
        s[i] = cross_prod(a[i], a[(i + 1) % n]);
        pref[i + 1] = pref[i] + s[i];
    }
    int i2 = log2(n - 2);
    for (int i = 0; i < n; i++) {
        {
            int nw = (i + 1) % n;
            for (int j = i2; j >= 0; j--) {
                int cur = (nw + (1 << j)) % n;
                if (cross_prod(a[nw] - a[i], a[cur] - a[i]) < 0 || cur == i) {
                    continue;
                }
                if (cross_prod(a[nw] - a[i], a[cur] - a[i]) == 0 && len(a[nw] - a[i]) > len(a[cur] - a[i])) {
                    continue;
                }
                if (cross_prod(a[cur] - a[i], c - a[i]) >= 0 && dist(c, line(a[i], a[cur])) >= 1ll * r * r) {
                    nw = cur;
                }
            }
            ans = max<ll>(ans, get(i, nw));
        }
        {
            int nw = (i + 1) % n;
            for (int j = i2; j >= 0; j--) {
                int cur = (nw + (1 << j)) % n;
                if (cross_prod(a[nw] - a[i], a[cur] - a[i]) < 0 || cur == i) {
                    continue;
                }
                if (cross_prod(a[nw] - a[i], a[cur] - a[i]) == 0 && len(a[nw] - a[i]) > len(a[cur] - a[i])) {
                    continue;
                }
                if (cross_prod(a[cur] - a[i], c - a[i]) >= 0 || dist(c, line(a[i], a[cur])) < 1ll * r * r) {
                    nw = cur;
                }
            }
            nw = (nw + 1) % n;
            ans = max<ll>(ans, pref[n] - get(i, nw));
        }
    }
    cout << ans << '\n';
}

详细

answer.code: In function ‘__int128 dist(const std::pair<long long int, long long int>&, line)’:
answer.code:51:15: error: call of overloaded ‘abs(__int128)’ is ambiguous
   51 |     return abs((__int128_t)1 * b[a] * b[a] / b.norm());
      |            ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/13/cstdlib:79,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:42,
                 from answer.code:1:
/usr/include/stdlib.h:840:12: note: candidate: ‘int abs(int)’
  840 | extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur;
      |            ^~~
In file included from /usr/include/c++/13/cstdlib:81:
/usr/include/c++/13/bits/std_abs.h:130:3: note: candidate: ‘constexpr __gnu_cxx::__bfloat16_t std::abs(__gnu_cxx::__bfloat16_t)’
  130 |   abs(__gnu_cxx::__bfloat16_t __x)
      |   ^~~
/usr/include/c++/13/bits/std_abs.h:124:3: note: candidate: ‘constexpr _Float128 std::abs(_Float128)’
  124 |   abs(_Float128 __x)
      |   ^~~
/usr/include/c++/13/bits/std_abs.h:114:3: note: candidate: ‘constexpr _Float64 std::abs(_Float64)’
  114 |   abs(_Float64 __x)
      |   ^~~
/usr/include/c++/13/bits/std_abs.h:108:3: note: candidate: ‘constexpr _Float32 std::abs(_Float32)’
  108 |   abs(_Float32 __x)
      |   ^~~
/usr/include/c++/13/bits/std_abs.h:102:3: note: candidate: ‘constexpr _Float16 std::abs(_Float16)’
  102 |   abs(_Float16 __x)
      |   ^~~
/usr/include/c++/13/bits/std_abs.h:79:3: note: candidate: ‘constexpr long double std::abs(long double)’
   79 |   abs(long double __x)
      |   ^~~
/usr/include/c++/13/bits/std_abs.h:75:3: note: candidate: ‘constexpr float std::abs(float)’
   75 |   abs(float __x)
      |   ^~~
/usr/include/c++/13/bits/std_abs.h:71:3: note: candidate: ‘constexpr double std::abs(double)’
   71 |   abs(double __x)
      |   ^~~
/usr/include/c++/13/bits/std_abs.h:61:3: note: candidate: ‘long long int std::abs(long long int)’
   61 |   abs(long long __x) { return __builtin_llabs (__x); }
      |   ^~~
/usr/include/c++/13/bits/std_abs.h:56:3: note: candidate: ‘long int std::abs(long int)’
   56 |   abs(long __i) { return __builtin_labs(__i); }
      |   ^~~