QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#313117#7730. Convex CheckerHHY_zZhuWA 14ms11404kbC++235.2kb2024-01-24 16:10:072024-01-24 16:10:08

Judging History

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

  • [2024-07-04 19:27:17]
  • hack成功,自动添加数据
  • (/hack/727)
  • [2024-07-04 19:17:30]
  • hack成功,自动添加数据
  • (/hack/726)
  • [2024-01-24 16:10:08]
  • 评测
  • 测评结果:WA
  • 用时:14ms
  • 内存:11404kb
  • [2024-01-24 16:10:07]
  • 提交

answer

//#pragma GCC optimize("O3, unroll-loops")
//#pragma GCC target("avx2, bmi, bmi2, lzcnt, popcnt")
#include <bits/stdc++.h>
using namespace std;
#define V vector
#define all0(x) (x).begin(), (x).end()
#define all1(x) (x).begin() + 1, (x).end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define cin std::cin
#define cout std::cout
typedef long long LL;
typedef pair<int, int> pi;
typedef pair<LL, LL> pl;
#ifdef LOCAL
#include "C:/Users/lijia/Desktop/vscode/algo/debug.h"
#else
#define debug(...) 42
#endif

//const int MN = 2e5 + 20;//MaxN 记得改一下
const int INF = 2e9 + 1000;//INF
const LL INFLL = 8e18 + 1000;//INF long long 
mt19937 mrand(random_device{}());
//模板区域~~~~~~~
#define db LL
const db EPS = 1e-9;
inline int sign(db a){ return a < -EPS ? -1 : a > EPS; }
inline int cmp(db a, db b){ return sign(a - b); }

struct P {
    db x, y;
    P operator+(P o){return {x + o.x, y + o.y};}
    P operator-(P o){return {x - o.x, y - o.y};}
    P operator*(db k){return {x * k, y * k};}
    P operator/(db k){return {x / k, y / k};}

    bool operator<(P o) const{
        int c = cmp(x, o.x);
        if (c) return c == -1;
        return cmp(y, o.y) == -1;
    }
    
    bool operator==(P o) const{
        return cmp(x,o.x) == 0 && cmp(y,o.y) == 0;
    }

    db dot(P o){ return x * o.x + y * o.y; }
    db det(P o){ return x * o.y - y * o.x; }
    
    db abs(){ return sqrt(abs()); }
    db abs2(){ return x * x + y * y; }
    db distTo(P p){ return (*this - p).abs(); }
    db alpha(){ return atan2(y, x); }
    P rot90(){ return {-y, x}; }
    P unit(){ return *this / abs(); }
    int quad() const {return sign(y) == 1 || (sign(y) == 0 && sign(x) >= 0); }
    P rot(db an){ return {x * cos(an) - y * sin(an), x * sin(an) + y * cos(an)}; }
    bool bef(P p){ return quad() < p.quad() || det(p) > 0; }//trying 

    void show(){ cout << "(" << x << "," << y << ")" << endl; }
    void read(){ cin >> x >> y; }
};
#define cross(p1, p2, p3) ((p2.x - p1.x) * (p3.y - p1.y) - (p3.x - p1.x) * (p2.y - p1.y))
#define crossOp(p1, p2, p3) sign(cross(p1, p2, p3))

//恰好一个交点
bool chkLL(P p1, P p2, P q1, P q2){
    db a1 = cross(q1, q2, p1), a2 = -cross(q1, q2, p2);
    return sign(a1 + a2) != 0;
}

P getLL(P p1, P p2, P q1, P q2){
    db a1 = cross(q1, q2, p1), a2 = -cross(q1, q2, p2);
    return (p1 * a2 + p2 * a1) / (a1 + a2);
}

bool intersect(db l1, db r1, db l2, db r2){
    if(l1 > r1) swap(l1, r1);
    if(l2 > r2) swap(l2, r2);
    return !(cmp(r1, l2) == -1 || cmp(r2, l1) == -1);
}

bool isSS(P p1, P p2, P q1, P q2){
    return intersect(p1.x, p2.x, q1.x, q2.x) && 
            intersect(p1.y, p2.y, q1.y, q2.y) &&
            crossOp(p1, p2, q1) * crossOp(p1, p2, q2) <= 0 &&
            crossOp(q1, q2, p1) * crossOp(q1, q2, p2) <= 0;
}

bool isSS_strict(P p1, P p2, P q1, P q2){
    return crossOp(p1, p2, q1) * crossOp(p1, p2, q2) < 0 &&
            crossOp(q1, q2, p1) * crossOp(q1, q2, p2) < 0;
}

bool isMid(db a, db m, db b){
    return sign(a - m) == 0 || sign(b - m) == 0 || (a < m != b < m);
}   

bool isMid(P a, P m, P b){
    return isMid(a.x, m.x, b.x) && isMid(a.y, b.y, m.y);
}

bool onSeg(P p1, P p2, P q){
    return crossOp(p1, p2, q) == 0 && isMid(p1, q, p2);
}

bool onSeg_strict(P p1, P p2, P q){
    return crossOp(p1, p2, q) == 0 &&
        sign((q - p1).dot(p1 - p2)) * sign((q - p2).dot(p1 - p2)) < 0;
}

P proj(P p1, P p2, P q){
    P dir = p2 - p1;
    return p1 + dir * (dir.dot(q - p1) / dir.abs2());
}

P reflect(P p1, P p2, P q){
    return proj(p1, p2, q) * 2 - q;
}

db nearest(P p1, P p2, P q){
    if(p1 == p2) return p1.distTo(q);
    P h = proj(p1, p2, q);
    if(isMid(p1, h, p2))
        return q.distTo(h);
    return min(p1.distTo(q), p2.distTo(q));
}

db dissSS(P p1, P p2, P q1, P q2){
    if(isSS(p1, p2, q1, q2)) return 0;
    return min({nearest(p1, p2, q1), nearest(p1, p2, q2),
                nearest(q1, q2, p1), nearest(q1, q2, p2)});
} 
//模板结束~~~~~~~

void solve() {
    int n; cin >> n;
    V<P> a(n * 2 + 1);
    for(int i = 1; i <= n; i++) {
        a[i].read();
        a[i + n] = a[i];
    }
    auto ok = [&n] (V<P> a) -> bool {
        P mn = {INFLL, INFLL};
        int s;
        for(int i = 1; i <= n; i++){
            if(a[i] < mn) {
                mn = a[i];
                s = i;
            }
        }
        debug(s);
        for(int i = n; i >= 1; i--) {
            a[i] = a[i] - a[1];
        }
        for(int i = s + 1; i < s + n - 1; i++) {
            if(a[i].det(a[i + 1]) <= 0) return 0;
            if((a[i] - a[i - 1]).det(a[i + 1] - a[i]) <= 0) return 0;
        }
        return 1;
    };
    if(ok(a)) cout << "Yes\n";
    else {
        reverse(all1(a));
        cout << (ok(a) ? "Yes\n" : "No\n");
    }
}
int32_t main() {
#ifndef LOCAL
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#endif
#ifdef LOCAL
   freopen("C:/Users/lijia/Desktop/vscode/in.in", "r", stdin);
   freopen("C:/Users/lijia/Desktop/vscode/out.out", "w", stdout);
#endif
    int tt = 1;
    //cin >> tt;
    while (tt--) 
    solve();
}

詳細信息

Test #1:

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

input:

3
0 0
1 0
0 1

output:

Yes

result:

ok answer is YES

Test #2:

score: 0
Accepted
time: 0ms
memory: 3488kb

input:

4
0 0
0 1
1 1
1 0

output:

Yes

result:

ok answer is YES

Test #3:

score: 0
Accepted
time: 0ms
memory: 3620kb

input:

4
0 0
0 3
1 2
1 1

output:

Yes

result:

ok answer is YES

Test #4:

score: 0
Accepted
time: 0ms
memory: 3760kb

input:

3
0 0
0 0
0 0

output:

No

result:

ok answer is NO

Test #5:

score: 0
Accepted
time: 0ms
memory: 3472kb

input:

5
1 0
4 1
0 1
2 0
3 2

output:

No

result:

ok answer is NO

Test #6:

score: 0
Accepted
time: 0ms
memory: 3492kb

input:

5
0 0
1000000000 0
1000000000 500000000
1000000000 1000000000
0 1000000000

output:

No

result:

ok answer is NO

Test #7:

score: 0
Accepted
time: 0ms
memory: 3444kb

input:

5
0 0
1000000000 0
1000000000 499999999
1000000000 1000000000
0 1000000000

output:

No

result:

ok answer is NO

Test #8:

score: 0
Accepted
time: 1ms
memory: 3820kb

input:

5
0 0
999999999 0
1000000000 50000000
999999999 1000000000
0 1000000000

output:

Yes

result:

ok answer is YES

Test #9:

score: -100
Wrong Answer
time: 14ms
memory: 11404kb

input:

128312
5578014 410408218
5585076 410404717
5588011 410403262
5588473 410403033
5589740 410402405
5593295 410400643
5593751 410400417
5597248 410398684
5598935 410397848
5600618 410397014
5605185 410394751
5610514 410392111
5614281 410390245
5617263 410388768
5621142 410386847
5630840 410382045
56310...

output:

No

result:

wrong answer expected YES, found NO