QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#851131#9434. Italian Cuisinetest_algthWA 0ms3932kbC++171.8kb2025-01-10 15:42:532025-01-10 15:42:53

Judging History

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

  • [2025-01-10 15:42:53]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3932kb
  • [2025-01-10 15:42:53]
  • 提交

answer

#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int MAXN = 2e5 + 5;
int n;
ll r;
struct Vector
{
    ll x,y;
    Vector operator - (const Vector &a)const
    {
        return Vector{x - a.x,y - a.y};
    }
    ll operator * (const Vector &a)const
    {
        return abs(x * a.y - y * a.x);
    }
    double length()
    {
        return sqrt(x * x + y * y);
    }
}dot[MAXN],rd;
double COS(Vector v1,Vector v2)
{
    return 1.0 * (v1.x * v2.x + v1.y * v2.y) / v1.length() / v2.length();
}
bool check(int i,int j)
{
    if(i + 1 >= j) return true;

    Vector v1 = dot[j] - dot[i],v2 = dot[j - 1] - dot[i],vr = rd - dot[i];

    // cout << v1.x << " " << v1.y << " " << v2.x << " " << v2.y << endl;
    // cout << COS(v1,v2) << " " << COS(v1,vr) << " " << COS(v2,vr) << endl;

    return !(COS(v1,v2) < COS(v1,vr) && COS(v1,v2) < COS(v2,vr)) && r <= v1 * vr / v1.length();
}
int main()
{
    int T;
    scanf("%d",&T);
    while(T--)
    {
        scanf("%d",&n);
        scanf("%lld %lld %lld",&rd.x,&rd.y,&r);
        for(int i = 1; i <= n; ++i)
            scanf("%lld %lld",&dot[i].x,&dot[i].y);
        for(int i = n + 1; i <= 2 * n; ++i)
            dot[i] = dot[i - n];
        int cur = 1;
        ll res = 0,now = 0;

        // cout << check(3,6) << endl;

        for(int i = 1 ; i <= n; ++i)
        {
            while(check(i,cur + 1) && cur < 2 * n)
            {
                now += (dot[cur] - dot[i]) * (dot[cur + 1] - dot[i]);
                ++cur;
                res = max(res,now);
            }
            // cout << "debug:" << i << " " << cur << " " << now << endl;
            now -= (dot[i] - dot[cur]) * (dot[i + 1] - dot[cur]);
        }
        printf("%lld\n",res);
    }
    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3932kb

input:

3
5
1 1 1
0 0
1 0
5 0
3 3
0 5
6
2 4 1
2 0
4 0
6 3
4 6
2 6
0 3
4
3 3 1
3 0
6 3
3 6
0 3

output:

5
24
0

result:

ok 3 number(s): "5 24 0"

Test #2:

score: -100
Wrong Answer
time: 0ms
memory: 3836kb

input:

1
6
0 0 499999993
197878055 -535013568
696616963 -535013568
696616963 40162440
696616963 499999993
-499999993 499999993
-499999993 -535013568

output:

286862654137719264

result:

wrong answer 1st numbers differ - expected: '0', found: '286862654137719264'