QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#599276#9434. Italian Cuisineucup-team2000#WA 0ms3736kbC++232.5kb2024-09-29 02:58:392024-09-29 02:58:39

Judging History

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

  • [2024-09-29 02:58:39]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3736kb
  • [2024-09-29 02:58:39]
  • 提交

answer

#include<bits/stdc++.h>

using namespace std;

using ll = long long;
using db = long double;

constexpr db eps = 1e-12;

struct point {
    ll x, y;

    point operator + (const point &a) const {
        return {x+a.x, y+a.y};
    }
    point operator - (const point &a) const {
        return {x-a.x, y-a.y};
    }
    ll operator * (const point &a) const {
        return x*a.x + y*a.y;
    }
    ll operator ^ (const point &a) const {
        return x*a.y - y*a.x;
    }
    int toleft(const point &a) const {
        const auto t = (*this) ^ a;
        return (t>0) - (t<0);
    }
    db len() const {
        return sqrtl(len2());
    }
    db len2() const {
        return (*this)*(*this);
    }
    db dis(const point &a) const {
        return sqrtl(((*this) - a).len2());
    }
};

struct line {
    point p, v;
    db dis(const point &a) const {
        return abs(v^(a-p))/v.len();
    }
    int toleft(const point &a) const {
        return v.toleft(a-p);
    }
};

struct circle {
    point c; ll r;
    
    // 1, c is on left of l
    // 0, c strictly intersects with l
    // -1, c is on right side
    int onleft(line &l) {
        auto d = l.dis(c);
        if(d < r - eps) return 0;
        return l.toleft(c);
    }
};


void solve() {
    int n; cin >> n;
    circle C;
    cin >> C.c.x >> C.c.y >> C.r;
    vector<point>vec(n);
    for(auto &[x, y]: vec) cin >> x >> y;
    vec.insert(end(vec), begin(vec), end(vec));
    // cout << "point1" << endl;
    // return;
    

    // 2*area of triangle (0, vec[i], vec[i+1])
    auto ask = [&](int id) {
        return vec[id]^vec[id+1];
    };
    auto ask2 = [&](int l, int r) {
        return vec[l]^vec[r];
    };
    auto check = [&](int l, int r) -> bool {
        line ln{vec[l], vec[r]-vec[l]};
        return C.onleft(ln)==1;
    };

    ll ans = 0;


    int count = 0;
    ll temp = 0;

    for(int i = 0, j = 0; i < n ; i ++) {
        if(i) temp -= ask(i-1); 
        while(check(i, j+1)) {
            // j, j+1, 0
            temp += ask(j);
            j++;
            //if(++count==10) break;
            //cout << i << ' ' << j << endl;
            //cout << "point3" << endl;
        }
        ans = max(ans, temp - ask2(i, j));
        
    }
    cout << ans << '\n';
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int t; cin >> t;
    while(t--) {
        solve();
    }

    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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

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'