QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#689603#9434. Italian CuisineDarwinA66WA 39ms7844kbC++203.2kb2024-10-30 17:55:352024-10-30 17:55:36

Judging History

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

  • [2024-10-30 17:55:36]
  • 评测
  • 测评结果:WA
  • 用时:39ms
  • 内存:7844kb
  • [2024-10-30 17:55:35]
  • 提交

answer

#include<bits/stdc++.h>
#define ll __int128_t
#define eps 1e-4
using namespace std;
// #define double long double
const int N=100010;
namespace my128 { // 读入优化封装,支持__int128
    using i64 = __int128_t;
    i64 abs(const i64 &x) {
        return x > 0 ? x : -x;
    }
    auto &operator>>(istream &it, i64 &j) {
        string val;
        it >> val;
        reverse(val.begin(), val.end());
        i64 ans = 0;
        bool f = 0;
        char c = val.back();
        val.pop_back();
        for (; c < '0' || c > '9'; c = val.back(), val.pop_back()) {
            if (c == '-') {
                f = 1;
            }
        }
        for (; c >= '0' && c <= '9'; c = val.back(), val.pop_back()) {
            ans = ans * 10 + c - '0';
        }
        j = f ? -ans : ans;
        return it;
    }
    auto &operator<<(ostream &os, const i64 &j) {
        string ans;
        function<void(i64)> write = [&](i64 x) {
            if (x < 0) ans += '-', x = -x;
            if (x > 9) write(x / 10);
            ans += x % 10 + '0';
        };
        write(j);
        return os << ans;
    }
} // namespace my128

using namespace my128;
struct point{
    ll x;
    ll y;
}P[N];
ll S[N];
ll S_s[N];
int n;
ll xr,yr,r;
ll M(point a,point b)
{
    return 1ll*a.x*b.y-1ll*b.x*a.y;
}
ll find_area(int left,int right)
{
    if(left<=right)return S_s[right-1]-S_s[left-1]-(M(P[left],P[right]));
    else{
        ll temp=S_s[n-1]-S_s[left-1]+S_s[right-1]+S[n];
        return temp-M(P[left],P[right]);
    }
}
double find_d(int left,int right)
{
    if(left==right)return sqrt(double(P[left].x*P[left].x+P[left].y*P[left].y))*1.00;
    double d1=sqrt(double((P[left].x-P[right].x)*(P[left].x-P[right].x)+(P[left].y-P[right].y))*(P[left].y-P[right].y))*1.00;
    double d=M(P[left],P[right])*1.00/d1;
    //printf("%d %d %lf %lf\n",left,right,d1,d);
    return d;
}
int main()
{
    int T;
    scanf("%d",&T);
    while(T--)
    {
        scanf("%d",&n);
        // scanf("%lld %lld %lld",&xr,&yr,&r);
        cin >> xr >> yr >> r;
        for(int i=1;i<=n;i++)
        {
            // scanf("%lld %lld",&P[i].x,&P[i].y);
            cin >> P[i].x >> P[i].y;
            P[i].x=(P[i].x)-xr*1ll;
            P[i].y=(P[i].y)-yr*1ll;
        }
        S_s[0]=0ll;
        for(int i=1;i<=n;i++)
        {
            if(i<n)S[i]=M(P[i],P[i+1]);
            else S[i]=M(P[i],P[1]);
            //printf("%lld\n",S[i]);
            S_s[i]=S_s[i-1]+S[i];
        }
        int curr=1;
        ll ans=0ll;
        for(int i=1;i<=n;i++)
        {
            while(find_d(i,(curr%n)+1)+eps>=1.00*r)
            {
                curr=(curr%n)+1;
                ll tp=find_area(i,curr);
                if(tp<0)tp=-tp;
                ans=max(1ll*ans,tp*1ll);
            }
        }
        curr=n;
        for(int i=n;i>=1;i--)
        {
            while(find_d(i,((curr+n-2)%n)+1)-eps<=-1.00*r)
            {
                curr=((curr+n-2)%n)+1;
                ll tp=find_area(curr,i);
                if(tp<0)tp=-tp;
                ans=max(ans*1ll,tp*1ll);
            }
        }
        // printf("%lld\n",ans);
        cout << ans << "\n";
        
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 7844kb

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: 0
Accepted
time: 0ms
memory: 5668kb

input:

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

output:

0

result:

ok 1 number(s): "0"

Test #3:

score: -100
Wrong Answer
time: 39ms
memory: 5712kb

input:

6666
19
-142 -128 26
-172 -74
-188 -86
-199 -157
-200 -172
-199 -186
-195 -200
-175 -197
-161 -188
-144 -177
-127 -162
-107 -144
-90 -126
-87 -116
-86 -104
-89 -97
-108 -86
-125 -80
-142 -74
-162 -72
16
-161 -161 17
-165 -190
-157 -196
-154 -197
-144 -200
-132 -200
-128 -191
-120 -172
-123 -163
-138...

output:

902
342
0
0
1846
665
3832
4141
2028
16
993
1084
190
549
0
4397
1193
5096
126
111
98
356
3933
671
2537
11112
78
4246
279
498
2432
13
302
2277
4202
3359
743
4036
9129
4363
4032
977
300
0
1047
1158
1670
976
2174
186
172
82
0
1122
286
60
1243
1421
823
936
2286
1770
421
835
731
256
0
1402
798
1332
2236
7...

result:

wrong answer 1st numbers differ - expected: '5093', found: '902'