QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#312743#7730. Convex CheckerAlbert711AC ✓17ms5372kbC++142.3kb2024-01-24 11:18:012024-07-04 19:17:42

Judging History

你现在查看的是测评时间为 2024-07-04 19:17:42 的历史记录

  • [2024-07-04 19:27:24]
  • 自动重测本题所有获得100分的提交记录
  • 测评结果:AC
  • 用时:17ms
  • 内存:5340kb
  • [2024-07-04 19:27:17]
  • hack成功,自动添加数据
  • (/hack/727)
  • [2024-07-04 19:17:42]
  • 自动重测本题所有获得100分的提交记录
  • 测评结果:100
  • 用时:17ms
  • 内存:5372kb
  • [2024-07-04 19:17:30]
  • hack成功,自动添加数据
  • (/hack/726)
  • [2024-01-24 11:18:02]
  • 评测
  • 测评结果:100
  • 用时:17ms
  • 内存:5316kb
  • [2024-01-24 11:18:01]
  • 提交

answer

#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef double db;
const int N = 1000 + 5;
#define int long long
const int mod = 1000000000;

struct point {
    int 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};
    }
};

int det(point &a, point &b) {
    return a.x * b.y - a.y * b.x;
}

void solve() {
    int n;
    cin >> n;
    vector<point> a(n + 3);
    for (int i = 0; i < n; i++) cin >> a[i].x >> a[i].y;
    a[n] = a[0];
    a[n + 1] = a[1];
    a[n + 2] = a[2];
    int jud = 0;
    int ans = 1;
    for (int i = 0; i < n; i++) {
        point tmp1 = (a[i + 1] - a[i]);
        point tmp2 = (a[i + 2] - a[i]);
        int tt = det(tmp1, tmp2);
        if (jud == 0) {
            if (tt > 0) {
                jud = 1;
            } else if (tt < 0) {
                jud = -1;
            } else {
                ans = 0;
            }
        } else {
            if (tt == 0 || (tt < 0 && jud == 1) || (tt > 0 && jud == -1)) ans = 0;
        }
    }
    jud = 0;
    point f = a[1] - a[0];
    for (int i = 2; i < n; i++) {
        point tmp = (a[i] - a[0]);
        int tt = det(f, tmp);
        if (jud == 0) {
            if (tt > 0) {
                jud = 1;
            } else if (tt < 0) {
                jud = -1;
            } else {
                ans = 0;
            }
        } else {
            if (tt == 0 || (tt < 0 && jud == 1) || (tt > 0 && jud == -1)) ans = 0;
        }
        f = tmp;
    }
    jud = 0;
    f = a[1] - a[0];
    for (int i = 2; i < n; i++) {
        point tmp = (a[i] - a[0]);
        int tt = det(f, tmp);
        if (jud == 0) {
            if (tt > 0) {
                jud = 1;
            } else if (tt < 0) {
                jud = -1;
            } else {
                ans = 0;
            }
        } else {
            if (tt == 0 || (tt < 0 && jud == 1) || (tt > 0 && jud == -1)) ans = 0;
        }
    }
    if (ans) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }

}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int T = 1;
//    cin >> T;
    while (T--) solve();
    return 0;
}


这程序好像有点Bug,我给组数据试试?

详细

Test #1:

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

input:

3
0 0
1 0
0 1

output:

Yes

result:

ok answer is YES

Test #2:

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

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

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

input:

3
0 0
0 0
0 0

output:

No

result:

ok answer is NO

Test #5:

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

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

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

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

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: 16ms
memory: 5252kb

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: 0
Accepted
time: 8ms
memory: 5372kb

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:

Yes

result:

ok answer is YES

Test #11:

score: 0
Accepted
time: 13ms
memory: 5156kb

input:

128369
146452483 526399214
146453715 526394712
146454820 526390674
146456370 526385008
146457099 526382343
146457964 526379180
146458751 526376302
146460091 526371401
146460722 526369093
146461114 526367659
146462323 526363236
146463053 526360565
146464791 526354204
146465863 526350280
146467488 526...

output:

Yes

result:

ok answer is YES

Test #12:

score: 0
Accepted
time: 13ms
memory: 5148kb

input:

128629
-49533670 490353833
-49532992 490346840
-49532611 490342912
-49531898 490335566
-49531313 490329543
-49531185 490328226
-49530713 490323370
-49530074 490316799
-49529672 490312668
-49528947 490305222
-49528647 490302143
-49528203 490297587
-49527568 490291076
-49527548 490290871
-49527039 490...

output:

Yes

result:

ok answer is YES

Test #13:

score: 0
Accepted
time: 17ms
memory: 5156kb

input:

128259
75790065 403382855
75793744 403383837
75801054 403385789
75805360 403386939
75810275 403388252
75813681 403389162
75820264 403390921
75830809 403393740
75832118 403394090
75837226 403395456
75840000 403396198
75844837 403397492
75849584 403398762
75852835 403399632
75860658 403401726
75865562...

output:

Yes

result:

ok answer is YES

Test #14:

score: 0
Accepted
time: 16ms
memory: 5168kb

input:

128166
46176199 599926866
46170746 599926657
46165737 599926465
46159641 599926231
46152002 599925937
46147638 599925769
46143595 599925613
46138544 599925418
46131124 599925131
46125834 599924926
46120627 599924724
46118799 599924653
46115505 599924525
46110055 599924313
46109413 599924288
46107744...

output:

No

result:

ok answer is NO

Test #15:

score: 0
Accepted
time: 12ms
memory: 5292kb

input:

128507
149999857 500169091
149999867 500163069
149999868 500162459
149999880 500154866
149999887 500150300
149999898 500142815
149999902 500139971
149999913 500131887
149999918 500128019
149999923 500124046
149999926 500121605
149999929 500119099
149999933 500115702
149999941 500108613
149999946 500...

output:

No

result:

ok answer is NO

Test #16:

score: 0
Accepted
time: 16ms
memory: 5184kb

input:

128133
140873382 458262385
140873715 458263110
140876530 458269240
140878601 458273750
140879764 458276283
140880913 458278786
140884549 458286707
140886668 458291324
140890730 458300177
140893254 458305679
140895530 458310641
140897744 458315468
140900237 458320905
140902076 458324916
140904176 458...

output:

No

result:

ok answer is NO

Test #17:

score: 0
Accepted
time: 17ms
memory: 5248kb

input:

128319
18407912 594878554
18403065 594876940
18399018 594875592
18391672 594873145
18389499 594872421
18386714 594871493
18383857 594870541
18370816 594866194
18363997 594863920
18356279 594861346
18349086 594858946
18343059 594856935
18338283 594855341
18334712 594854149
18329890 594852539
18326410...

output:

No

result:

ok answer is NO

Test #18:

score: 0
Accepted
time: 12ms
memory: 5144kb

input:

128502
10448094 591845777
10450502 591846814
10453758 591848216
10459200 591850559
10461337 591851479
10463544 591852429
10473696 591856798
10479318 591859217
10480608 591859772
10483502 591861017
10487533 591862751
10490644 591864089
10494176 591865608
10495627 591866232
10505163 591870332
10509490...

output:

No

result:

ok answer is NO

Extra Test:

score: 0
Extra Test Passed