QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#605406#9434. Italian Cuisine123adadCompile Error//C++202.0kb2024-10-02 17:05:102024-10-02 17:05:11

Judging History

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

  • [2024-10-02 17:05:11]
  • 评测
  • [2024-10-02 17:05:10]
  • 提交

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};
}

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]));
            // 如果在另一侧,说明新加边与圆相交或凸包包含了圆,移动l
            if (s <= 0)
                break;
            // s同时也是新加边与圆心构成的三角形的面积的两倍,利用s=len*d计算边与圆心的距离
            // 如果距离小于R,说明新加边与圆相交,移动l
            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
            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), std::cin.tie(nullptr), std::cout.tie(nullptr);
    int _ = 1;
    // std::cin >> _;
    read(_);
    while (_--)
    {
        solve();
    }
    return 0;
}

详细

answer.code: In function ‘void solve()’:
answer.code:36:9: error: too few arguments to function ‘ssize_t read(int, void*, size_t)’
   36 |     read(n);
      |     ~~~~^~~
In file included from /usr/include/unistd.h:1166,
                 from /usr/include/c++/13/bits/atomic_wait.h:44,
                 from /usr/include/c++/13/bits/atomic_base.h:42,
                 from /usr/include/c++/13/bits/shared_ptr_atomic.h:33,
                 from /usr/include/c++/13/memory:81,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:56,
                 from answer.code:1:
/usr/include/x86_64-linux-gnu/bits/unistd.h:34:1: note: declared here
   34 | read (int __fd, void *__buf, size_t __nbytes)
      | ^~~~
answer.code:39:9: error: too few arguments to function ‘ssize_t read(int, void*, size_t)’
   39 |     read(C.x);
      |     ~~~~^~~~~
/usr/include/x86_64-linux-gnu/bits/unistd.h:34:1: note: declared here
   34 | read (int __fd, void *__buf, size_t __nbytes)
      | ^~~~
answer.code:40:9: error: too few arguments to function ‘ssize_t read(int, void*, size_t)’
   40 |     read(C.y);
      |     ~~~~^~~~~
/usr/include/x86_64-linux-gnu/bits/unistd.h:34:1: note: declared here
   34 | read (int __fd, void *__buf, size_t __nbytes)
      | ^~~~
answer.code:43:9: error: too few arguments to function ‘ssize_t read(int, void*, size_t)’
   43 |     read(R);
      |     ~~~~^~~
/usr/include/x86_64-linux-gnu/bits/unistd.h:34:1: note: declared here
   34 | read (int __fd, void *__buf, size_t __nbytes)
      | ^~~~
answer.code:48:13: error: too few arguments to function ‘ssize_t read(int, void*, size_t)’
   48 |         read(a[i].x);
      |         ~~~~^~~~~~~~
/usr/include/x86_64-linux-gnu/bits/unistd.h:34:1: note: declared here
   34 | read (int __fd, void *__buf, size_t __nbytes)
      | ^~~~
answer.code:49:13: error: too few arguments to function ‘ssize_t read(int, void*, size_t)’
   49 |         read(a[i].y);
      |         ~~~~^~~~~~~~
/usr/include/x86_64-linux-gnu/bits/unistd.h:34:1: note: declared here
   34 | read (int __fd, void *__buf, size_t __nbytes)
      | ^~~~
answer.code:79:10: error: too few arguments to function ‘ssize_t write(int, const void*, size_t)’
   79 |     write(ans);
      |     ~~~~~^~~~~
/usr/include/unistd.h:366:16: note: declared here
  366 | extern ssize_t write (int __fd, const void *__buf, size_t __n) __wur;
      |                ^~~~~
answer.code: In function ‘int main()’:
answer.code:88:9: error: too few arguments to function ‘ssize_t read(int, void*, size_t)’
   88 |     read(_);
      |     ~~~~^~~
/usr/include/x86_64-linux-gnu/bits/unistd.h:34:1: note: declared here
   34 | read (int __fd, void *__buf, size_t __nbytes)
      | ^~~~