QOJ.ac

QOJ

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

Judging History

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

  • [2024-10-02 17:03:45]
  • 评测
  • [2024-10-02 17:03:43]
  • 提交

answer

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:2:9: error: ‘pair’ does not name a type
    2 | typedef pair<lll, lll> P;
      |         ^~~~
answer.code:8:11: error: ‘P’ was not declared in this scope
    8 | lll cross(P a, P b)
      |           ^
answer.code:8:16: error: ‘P’ was not declared in this scope
    8 | lll cross(P a, P b)
      |                ^
answer.code:8:19: error: expression list treated as compound expression in initializer [-fpermissive]
    8 | lll cross(P a, P b)
      |                   ^
answer.code:14:9: error: ‘P’ was not declared in this scope
   14 | lll mul(P a, P b)
      |         ^
answer.code:14:14: error: ‘P’ was not declared in this scope
   14 | lll mul(P a, P b)
      |              ^
answer.code:14:17: error: expression list treated as compound expression in initializer [-fpermissive]
   14 | lll mul(P a, P b)
      |                 ^
answer.code:20:5: error: redefinition of ‘lll mul’
   20 | lll mul(P a)
      |     ^~~
answer.code:14:5: note: ‘lll mul’ previously defined here
   14 | lll mul(P a, P b)
      |     ^~~
answer.code:20:9: error: ‘P’ was not declared in this scope
   20 | lll mul(P a)
      |         ^
answer.code:26:1: error: ‘P’ does not name a type
   26 | P del(P a, P b)
      | ^
answer.code: In function ‘void solve()’:
answer.code:34:5: error: ‘read’ was not declared in this scope
   34 |     read(n);
      |     ^~~~
answer.code:36:5: error: ‘P’ was not declared in this scope
   36 |     P C;
      |     ^
answer.code:37:10: error: ‘C’ was not declared in this scope
   37 |     read(C.x);
      |          ^
answer.code:43:5: error: ‘vector’ was not declared in this scope
   43 |     vector<P> a(n);
      |     ^~~~~~
answer.code:43:15: error: ‘a’ was not declared in this scope
   43 |     vector<P> a(n);
      |               ^
answer.code:58:27: error: ‘del’ was not declared in this scope
   58 |             lll s = cross(del(a[rr], a[l]), del(C, a[l]));
      |                           ^~~
answer.code:58:57: error: ‘cross’ cannot be used as a function
   58 |             lll s = cross(del(a[rr], a[l]), del(C, a[l]));
      |                                                         ^
answer.code:64:45: error: ‘mul’ cannot be used as a function
   64 |             if (s * s < mul(del(a[rr], a[l])) * R * R)
      |                                             ^
answer.code:67:57: error: ‘cross’ cannot be used as a function
   67 |             S += cross(del(a[r], a[l]), del(a[rr], a[l]));
      |                                                         ^
answer.code:71:15: error: ‘max’ was not declared in this scope
   71 |         ans = max(ans, S);
      |               ^~~
answer.code:75:20: error: ‘del’ was not declared in this scope
   75 |         S -= cross(del(a[r], a[l]), del(a[r], a[ll]));
      |                    ^~~
answer.code:75:53: error: ‘cross’ cannot be used as a function
   75 |         S -= cross(del(a[r], a[l]), del(a[r], a[ll]));
      |                                                     ^
answer.code:77:5: error: ‘write’ was not declared in this scope
   77 |     write(ans);
      |     ^~~~~
answer.code:78:5: error: ‘putchar’ was not declared in this scope; did you mean ‘char’?
   78 |     putchar('\n');
      |     ^~~~~~~
      |     char
answer.code: In function ‘int main()’:
answer.code:86:5: error: ‘read’ was not declared in this scope
   86 |     read(_);
      |     ^~~~