QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#406152#7730. Convex CheckerRainningLoveWA 1ms3772kbC++201.5kb2024-05-06 21:16:132024-05-06 21:16:15

Judging History

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

  • [2024-07-04 19:27:17]
  • hack成功,自动添加数据
  • (/hack/727)
  • [2024-07-04 19:17:30]
  • hack成功,自动添加数据
  • (/hack/726)
  • [2024-05-06 21:16:15]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3772kb
  • [2024-05-06 21:16:13]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;

struct Point {
    long double x,y;

    friend bool operator<(Point a,Point b) {
        if(a.x==b.x)return a.y<b.y;
        return a.x<b.x;
    }

    Point(long long x,long long y) {
        this->x=x;
        this->y=y;
    }
};

struct Line {
    long double A,B,C;

    Line(Point a,Point b) {
        this->A = b.y-a.y;
        this->B = a.x-b.x;
        this->C = a.y*b.x - a.x*b.y;
    }

    int contains(Point x) {
        if(A*x.x + B*x.y+C==0) return 1;
        return 0;
    }
};

struct Vector {
    long long x,y;

    Vector(Point a,Point b) {
        this->x=b.x-a.x;
        this->y=b.y-a.y;
    }
};

int n;
vector<Point> a;
void solve() {
    cin>>n;
    set<Point> st;
    for(int i=1;i<=n;i++) {
        long long x,y;
        cin>>x>>y;
        a.push_back(Point(x,y));
    }
    for(int i=0;i<n;i++) a.push_back(a[i]),st.insert(a[i]);
    if(st.size()!=n) return(void)(cout<<"No");

    int f=1;
    for(int i=1;i<=n;i++) {
        Vector x(a[i-1],a[i]),y(a[i],a[i+1]);
        if(x.x*y.y-x.y*y.x<=0) f=0;
    }

    if(f) return (void)(cout<<"Yes");

    f=1;
    for(int i=1;i<=n;i++) {
        Vector x(a[i-1],a[i]),y(a[i],a[i+1]);
        if(x.x*y.y-x.y*y.x>=0) f=0;
    }

    if(f) return (void)(cout<<"Yes");

    cout<<"No";

}

/*
(1,0)
(0,1)
a.x*b.y-a.y*b.x>0 a在b右侧
*/

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);

    int t=1;
    // cin>>t;
    while(t--)
    solve();
}

/*

*/

详细

Test #1:

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

input:

3
0 0
1 0
0 1

output:

Yes

result:

ok answer is YES

Test #2:

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

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

input:

4
0 0
0 3
1 2
1 1

output:

Yes

result:

ok answer is YES

Test #4:

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

input:

3
0 0
0 0
0 0

output:

No

result:

ok answer is NO

Test #5:

score: -100
Wrong Answer
time: 1ms
memory: 3528kb

input:

5
1 0
4 1
0 1
2 0
3 2

output:

Yes

result:

wrong answer expected NO, found YES