QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#672500#7906. Almost ConvexguodongWA 379ms6328kbC++171.8kb2024-10-24 17:05:502024-10-24 17:05:50

Judging History

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

  • [2024-10-24 17:05:50]
  • 评测
  • 测评结果:WA
  • 用时:379ms
  • 内存:6328kb
  • [2024-10-24 17:05:50]
  • 提交

answer

#include <bits/stdc++.h>
#define For(i,a,b) for(int i = a; i <= b; ++i)
#define int long long 
using namespace std;
const int N = 100200;
int q[N];
struct P{
    int x,y;
}a[N];
bool cmp(P a,P b){
    if(a.x == b.x) 
        return a.y < b.y;
    return a.x < b.x;
}
signed main()
{
    int A,B,C,D,r = 0,t;
    ios::sync_with_stdio(false);
    #ifdef NICEGUODONG
        freopen("data.in","r",stdin);
        ios::sync_with_stdio(true);
    #endif
    A = C = ~0U>>1;
    B = D = -A;
    int n;
    cin >> n;
    For(i,1,n){
        cin >> a[i].x >> a[i].y;
        A = min(A,a[i].x);
        B = max(B,a[i].x);
        C = min(C,a[i].y);
        D = max(D,a[i].y);
    }
    sort(a + 1, a + n + 1,cmp);
    t = 0;
    For(i,1,n)
        if(!t || a[i].y > r)
            r = a[i].y,q[++t] =i; 
    for(int i = q[r = t] + 1; i <= n; q[++t] = i++)
        while(t > r && a[i].y >= a[q[t]].y)
            t--;
    vector<int> Mark(n + 1);
    For(i,1,t){
        Mark[q[i]] = 1;
    }
    t = 0;  
    For(i,1,n)
        if(!t || a[i].y < r)
            r = a[i].y,q[++t] =i; 
            int i;
    for(i = q[r = t] + 1,i=q[t] +1; i <= n; q[++t] = i++)
        while(t > r && a[i].y <= a[q[t]].y)
            t--;
    int ans = 1;   For(i,1,t){
        Mark[q[i]] = 1;
    }
    for(int i = 1; i <= n; ++i){
        vector<pair<long double,int>> p;
        if(Mark[i]) continue;
        for(int j = 1; j <= n; ++j){
            if(i == j) continue;
            p.push_back(make_pair(atan2(a[j].y - a[i].y,a[j].x - a[i].x),j));
        }
        sort(p.begin(),p.end());
        if(p.size() == 0) continue;
        for(int i = 0;i < (int)p.size(); ++i)
            if(Mark[p[i].second] && Mark[p[(i + 1) % p.size()].second]){
ans++;
            }
    }
    cout << ans << '\n';
    return 0;
}

详细

Test #1:

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

input:

7
1 4
4 0
2 3
3 1
3 5
0 0
2 4

output:

9

result:

ok 1 number(s): "9"

Test #2:

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

input:

5
4 0
0 0
2 1
3 3
3 1

output:

5

result:

ok 1 number(s): "5"

Test #3:

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

input:

3
0 0
3 0
0 3

output:

1

result:

ok 1 number(s): "1"

Test #4:

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

input:

6
0 0
3 0
3 2
0 2
1 1
2 1

output:

7

result:

ok 1 number(s): "7"

Test #5:

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

input:

4
0 0
0 3
3 0
3 3

output:

1

result:

ok 1 number(s): "1"

Test #6:

score: -100
Wrong Answer
time: 379ms
memory: 6328kb

input:

2000
86166 617851
383354 -277127
844986 386868
-577988 453392
-341125 -386775
-543914 -210860
-429613 606701
-343534 893727
841399 339305
446761 -327040
-218558 -907983
787284 361823
950395 287044
-351577 -843823
-198755 138512
-306560 -483261
-487474 -857400
885637 -240518
-297576 603522
-748283 33...

output:

10959

result:

wrong answer 1st numbers differ - expected: '718', found: '10959'