QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#601931#9434. Italian CuisineSy03WA 18ms3828kbC++203.1kb2024-09-30 16:10:232024-09-30 16:10:24

Judging History

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

  • [2024-09-30 16:10:24]
  • 评测
  • 测评结果:WA
  • 用时:18ms
  • 内存:3828kb
  • [2024-09-30 16:10:23]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
using ui = unsigned int;
using ull = unsigned long long;
using ll = long long;
#define endl '\n'
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int maxn = 2e5 + 10;
const int mod = 1000000007;
#define inl inline
#define fr(i, a, b) for (int i = a; i <= b; i++)
#define ford(i, a, b) for (int i = a; i >= b; i--)
#define forall(i, a) for (auto &i : a)

/**
   ____         ___ _____
  / ___| _   _ / _ \___ /
  \___ \| | | | | | ||_ \
   ___) | |_| | |_| |__) |
  |____/ \__, |\___/____/
         |___/
*/
istream &operator>>(istream &in, vector<int> &v)
{
    for (auto &i : v)
        in >> i;
    return in;
}
ostream &operator<<(ostream &out, vector<int> &v)
{
    for (auto &i : v)
        out << i << " ";
    return out;
}
bool _output = 1;

#define i64 __int128_t
void print(i64 x)
{
    if (x < 0)
        putchar('-'), x = -x;
    if (x > 9)
        print(x / 10);
    putchar(x % 10 + '0');
}

struct P
{
    i64 x, y;
    P operator-(const P &a) const { return {x - a.x, y - a.y}; }
    i64 operator^(const P &a) const
    {
        return (i64)x * a.y - (i64)y * a.x;
    }
    i64 toleft(const P &a) const { return (i64)x * a.y - (i64)y * a.x; }
};
// ll cross(P a, P b) { return (i64)a.x * b.y - (i64)a.y * b.x; }
struct CIR
{
    i64 x, y, r;
    P c;
};
struct L
{
    P p, v;
    L(P p, P v) : p(p), v(v) {}
    bool dis(P &a, i64 r)
    {
        i64 t1 = (v ^ (a - p));
        // i64 t = t1 / sqrt((ll)v.x * (ll)v.x + (ll)v.y * (ll)(v.y));
        // cout << "area = ";
        // print(t);
        // cout << "  t1 = ";
        // print(t1);
        // cout << endl;
        return (i64)t1 * t1 <= (i64)r * r * (v.x * v.x + v.y * v.y);
    }
    i64 toleft(P &a)
    {
        return v ^ (a - p);
    }
};

void solve()
{
    int n;
    cin >> n;
    vector<P> a(n);
    CIR c;
    ll cx, cy, cr;
    cin >> cx >> cy >> cr;
    c.x = cx, c.y = cy, c.r = cr;
    P cc;
    cc.x = c.x, cc.y = c.y;
    c.c = cc;
    for (int i = 0; i < n; i++)
    {
        ll x, y;
        cin >> x >> y;
        a[i].x = x;
        a[i].y = y;
    }
    auto check_line_circle = [&](P x, P y)
    {
        L l = {x, y - x};
        if (l.dis(c.c, c.r))
        {
            return false;
        }
        return l.toleft(c.c) > 0;
    };
    int j = 0;
    i64 now = 0;
    i64 ans = 0;
    for (int i = 0; i < n; i++)
    {
        if (i)
        {
            now -= (i64)(a[i - 1] ^ a[i]);
        }
        j = max(j, i);
        while ((j + 1) % n != i && check_line_circle(a[i], a[(j + 1) % n]))
        {
            now += (i64)(a[j] ^ a[(j + 1) % n]);
            // print(now);
            // cout << endl;
            j++;
        }
        i64 t = now + (i64)(a[j] ^ a[i]);
        if (abs(j - i) >= 2)
            ans = max(ans, t);
    }

    print(ans);
    putchar('\n');
}
signed main()
{
    ios::sync_with_stdio(false);
    // cin.tie(0);
    // cout.tie(0);
    int _ = 1;
    if (_output)
        cin >> _;
    while (_--)
        solve();
    return 0;
}

详细

Test #1:

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

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: 3528kb

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: 18ms
memory: 3828kb

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:

5093
2862
1753
668
3535
7421
4883
4842
332369456042376730603691247744869478
1034
1642
290385945805314947974547779602087437
145725373346028433568995956203880295574
349862585307552569208349195025515838
103209462664695739278378390618389049
332369456042050795082652873677315121
25889831312685964718751708...

result:

wrong answer 2nd numbers differ - expected: '3086', found: '2862'