QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#454917#7730. Convex CheckerNephrennWA 20ms5176kbC++201.5kb2024-06-25 16:39:212024-06-25 16:39:21

Judging History

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

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

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

const int MAXN = 1e2 + 10;
const int INF = 0x3f3f3f3f;
const ll INFLL = 0x3f3f3f3f3f3f3f3f;

random_device seed;
mt19937 rnd(seed());
mt19937_64 rnd_64(seed());

const double eps = 1e-8;
int sgn(double x) {
    return x < -eps ? -1 : (x > eps ? 1 : 0);
}

struct Point {
    ll x, y;
    Point operator - (const Point &a) {
        return {x - a.x, y - a.y};
    }
};

ll dot(const Point &a, const Point &b) {
    return a.x * b.x + a.y * b.y;
}

ll det(const Point &a, const Point &b) {
    return a.x * b.y - a.y * b.x;
}

double len(const Point &a) {
    return sqrt(a.x * a.x + a.y * a.y);
}

double theta(const Point &a, const Point &b) {
    return acos(1.0 * dot(a, b) / len(a) / len(b));
}

void solve () {
    int n;
    cin >> n;
    vector<Point> p(n);
    double sum = 0;
    for(int i = 0; i < n; ++i) cin >> p[i].x >> p[i].y;
    for(int i = 0; i < n; ++i) {
        int i1 = i, i2 = (i + 1) % n, i3 = (i + 2) % n;
        Point v1 = p[i2] - p[i1], v2 = p[i3] - p[i2];

        if(sgn(det(v1, v2)) == 0) {
            cout << "No\n";
            return;
        }

        sum += theta(v1, v2);
    }

    if(sgn(sum - 2 * acos(-1)) == 0) cout << "Yes\n";
    else cout << "No\n";
}

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

    int Task = 1;
    while (Task--) {
        solve();
    }

    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

3
0 0
1 0
0 1

output:

Yes

result:

ok answer is YES

Test #2:

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

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

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

input:

3
0 0
0 0
0 0

output:

No

result:

ok answer is NO

Test #5:

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

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

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

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: 0ms
memory: 3800kb

input:

5
0 0
999999999 0
1000000000 50000000
999999999 1000000000
0 1000000000

output:

Yes

result:

ok answer is YES

Test #9:

score: 0
Accepted
time: 20ms
memory: 5176kb

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:

Yes

result:

ok answer is YES

Test #10:

score: -100
Wrong Answer
time: 16ms
memory: 5124kb

input:

128086
149550602 509469827
149551059 509465022
149551336 509462107
149551964 509455497
149552572 509449094
149553350 509440895
149553656 509437667
149554161 509432339
149554254 509431357
149554545 509428284
149555017 509423299
149555366 509419611
149555842 509414580
149556382 509408867
149556564 509...

output:

No

result:

wrong answer expected YES, found NO