QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#680571#9434. Italian CuisinepotentialCompile Error//C++201.9kb2024-10-26 21:35:032024-10-26 21:35:04

Judging History

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

  • [2024-10-26 21:35:04]
  • 评测
  • [2024-10-26 21:35:03]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

typedef __int128_t lll;
typedef pair<lll, lll> P;

#define x first
#define y second

// 叉乘
lll cross(P a, P b) {
    return a.x * b.y - a.y * b.x;
}

// 点积
lll mul(P a, P b) {
    return a.x * b.x + a.y * b.y;
}

// 点平方和
lll mul(P a) {
    return a.x * a.x + a.y * a.y;
}

// 计算矢量
P del(P a, P b) {
    return {a.x - b.x, a.y - b.y};
}

// 自定义的__int128输入函数
void read(lll &x) {
    string s;
    cin >> s;
    x = 0;
    bool neg = (s[0] == '-');
    for (int i = neg; i < s.size(); ++i) {
        x = x * 10 + (s[i] - '0');
    }
    if (neg) x = -x;
}

// 自定义的__int128输出函数
void write(lll x) {
    if (x < 0) {
        putchar('-');
        x = -x;
    }
    string s;
    do {
        s += '0' + x % 10;
        x /= 10;
    } while (x > 0);
    reverse(s.begin(), s.end());
    for (char c : s) putchar(c);
}

void solve() {
    int n;
    read(n);

    P C;
    read(C.x);
    read(C.y);

    lll R;
    read(R);

    vector<P> a(n);
    for (int i = 0; i < n; i++) {
        read(a[i].x);
        read(a[i].y);
    }

    lll ans = 0;
    lll S = 0;
    for (int l = 0, r = l + 1; l < n; l++) {
        while (1) {
            int rr = r % n + 1;
            lll s = cross(del(a[rr], a[l]), del(C, a[l]));
            if (s <= 0) break;
            if (s * s < mul(del(a[rr], a[l])) * R * R) break;
            S += cross(del(a[r], a[l]), del(a[rr], a[l]));
            r = rr;
        }
        ans = max(ans, S);
        int ll = l % n + 1;
        S -= cross(del(a[r], a[l]), del(a[r], a[ll]));
    }
    write(ans);
    putchar('\n');
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    int _ = 1;
    read(_);
    while (_--) {
        solve();
    }
    return 0;
}

Details

answer.code: In function ‘void solve()’:
answer.code:59:10: error: cannot bind non-const lvalue reference of type ‘lll&’ {aka ‘__int128&’} to a value of type ‘int’
   59 |     read(n);
      |          ^
answer.code:7:11: note:   initializing argument 1 of ‘void read(lll&)’
    7 | #define x first
      |           ^
answer.code:31:16: note: in expansion of macro ‘x’
   31 | void read(lll &x) {
      |                ^
answer.code: In function ‘int main()’:
answer.code:99:10: error: cannot bind non-const lvalue reference of type ‘lll&’ {aka ‘__int128&’} to a value of type ‘int’
   99 |     read(_);
      |          ^
answer.code:7:11: note:   initializing argument 1 of ‘void read(lll&)’
    7 | #define x first
      |           ^
answer.code:31:16: note: in expansion of macro ‘x’
   31 | void read(lll &x) {
      |                ^