QOJ.ac

QOJ

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

Judging History

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

  • [2024-10-02 17:04:26]
  • 评测
  • [2024-10-02 17:04:24]
  • 提交

answer

#include <bits/stdc++.h>
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:3:9: error: ‘pair’ does not name a type
    3 | typedef pair<lll, lll> P;
      |         ^~~~
answer.code:9:11: error: ‘P’ was not declared in this scope
    9 | lll cross(P a, P b)
      |           ^
answer.code:9:16: error: ‘P’ was not declared in this scope
    9 | lll cross(P a, P b)
      |                ^
answer.code:9:19: error: expression list treated as compound expression in initializer [-fpermissive]
    9 | lll cross(P a, P b)
      |                   ^
answer.code:15:9: error: ‘P’ was not declared in this scope
   15 | lll mul(P a, P b)
      |         ^
answer.code:15:14: error: ‘P’ was not declared in this scope
   15 | lll mul(P a, P b)
      |              ^
answer.code:15:17: error: expression list treated as compound expression in initializer [-fpermissive]
   15 | lll mul(P a, P b)
      |                 ^
answer.code:21:5: error: redefinition of ‘lll mul’
   21 | lll mul(P a)
      |     ^~~
answer.code:15:5: note: ‘lll mul’ previously defined here
   15 | lll mul(P a, P b)
      |     ^~~
answer.code:21:9: error: ‘P’ was not declared in this scope
   21 | lll mul(P a)
      |         ^
answer.code:27:1: error: ‘P’ does not name a type
   27 | P del(P a, P b)
      | ^
answer.code: In function ‘void solve()’:
answer.code:35:9: error: too few arguments to function ‘ssize_t read(int, void*, size_t)’
   35 |     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:37:5: error: ‘P’ was not declared in this scope
   37 |     P C;
      |     ^
answer.code:38:10: error: ‘C’ was not declared in this scope
   38 |     read(C.x);
      |          ^
answer.code:42:9: error: too few arguments to function ‘ssize_t read(int, void*, size_t)’
   42 |     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:44:5: error: ‘vector’ was not declared in this scope
   44 |     vector<P> a(n);
      |     ^~~~~~
answer.code:44:5: note: suggested alternatives:
In file included from /usr/include/c++/13/vector:66,
                 from /usr/include/c++/13/functional:64,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:53:
/usr/include/c++/13/bits/stl_vector.h:425:11: note:   ‘std::vector’
  425 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
/usr/include/c++/13/vector:86:13: note:   ‘std::pmr::vector’
   86 |       using vector = std::vector<_Tp, polymorphic_allocator<_Tp>>;
      |             ^~~~~~
answer.code:44:15: error: ‘a’ was not declared in this scope
   44 |     vector<P> a(n);
      |               ^
answer.code:59:27: error: ‘del’ was not declared in this scope
   59 |             lll s = cross(del(a[rr], a[l]), del(C, a[l]));
      |                           ^~~
answer.code:59:57: error: ‘cross’ cannot be used as a function
   59 |             lll s = cross(del(a[rr], a[l]), del(C, a[l]));
      |                                                         ^
answer.code:65:45: error: ‘mul’ cannot be used as a function
   65 |             if (s * s < mul(del(a[rr], a[l])) * R * R)
      |                                             ^
answer.code:68:57: error: ‘cross’ cannot be used as a function
   68 |             S += cross(del(a[r], a[l]), del(a[rr], a[l]));
      |                                                         ^
answer.code:72:15: error: ‘max’ was not declared in this scope
   72 |         ans = max(ans, S);
      |               ^~~
answer.code:72:15: note: suggested alternatives:
In file included from /usr/include/c++/13/algorithm:61,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:51:
/usr/include/c++/13/bits/stl_algo.h:5805:5: note:   ‘std::max’
 5805 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
In file included from /usr/include/c++/13/algorithm:63:
/usr/include/c++/13/bits/ranges_algo.h:2928:29: note:   ‘std::ranges::max’
 2928 |   inline constexpr __max_fn max{};
      |                             ^~~
answer.code:76:20: error: ‘del’ was not declared in this scope
   76 |         S -= cross(del(a[r], a[l]), del(a[r], a[ll]));
      |                    ^~~
answer.code:76:53: error: ‘cross’ cannot be used as a function
   76 |         S -= cross(del(a[r], a[l]), del(a[r], a[ll]));
      |                                                     ^
answer.code:78:10: error: too few arguments to function ‘ssize_t...