QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#196104#2838. 2D GeometryCSU2023#WA 2ms9932kbC++141.2kb2023-10-01 12:29:042023-10-01 12:29:05

Judging History

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

  • [2023-10-01 12:29:05]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:9932kb
  • [2023-10-01 12:29:04]
  • 提交

answer

#include <bits/stdc++.h>
#define LL long long
const int N = 2e5 + 3;
struct point{
    LL x,y;
    void read(){
        LL a,b;
        scanf("%lld%lld",&a,&b);
        x = a,y = b;
    }
    point(LL x = 0,LL y = 0) : x(x),y(y){}
    point operator+(const point &r)const{return point(x + r.x,y + r.y);}
    point operator-(const point &r)const{return point(x - r.x,y - r.y);}
    LL operator*(const point&r){return x * r.y - y * r.x;}
}p[N],s[N];
int n,top;

int main()
{
    freopen("a.txt","r",stdin);
    while(scanf("%d",&n) != EOF){
        top = 0;
        for(int i = 1;i <= n;++i){
            p[i].read();
            bool flag = 0;
            while(top >= 2 && (s[top - 1] - s[top - 2]) * (p[i] - s[top - 1]) != 0){
                flag = 1;
                top -= 2;
            }
            if(!flag) s[++top] = p[i];
         //   printf("GG");
        }
     //   printf("top:%d\n",top);
        if(top < 3) printf("%d\n",top);
        else{
            int sum = 0;
            for(int i = 1;i <= n;++i){
                if(((s[1] - s[2]) * (s[1] - p[i])) == 0) sum++;
            }
            printf("%d\n",std::max(0,n - (n - sum) * 3));
        }

    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 2ms
memory: 9932kb

input:

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

output:


result:

wrong answer 1st lines differ - expected: '3', found: ''