QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#196114#2838. 2D GeometryCSU2023#WA 1ms10036kbC++141.2kb2023-10-01 12:39:482023-10-01 12:39:48

Judging History

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

  • [2023-10-01 12:39:48]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:10036kb
  • [2023-10-01 12:39:48]
  • 提交

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();

            if(top >= 2 && (s[top - 1] - s[top - 2]) * (p[i] - s[top - 1]) != 0){

                top -= 2;
            }
                else 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;
}

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 10036kb

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:

3
0
0

result:

ok 3 lines

Test #2:

score: -100
Wrong Answer
time: 0ms
memory: 10000kb

input:

1
0 0
2
0 0
1 1
3
0 0
0 1
0 2
3
0 0
0 1
1 0
4
3 0
0 2
3 3
3 1
4
2 3
1 1
0 3
0 2
4
0 0
0 3
0 2
0 1
5
8 6
9 2
2 3
7 4
1 5
5
2 2
4 2
6 2
7 2
0 4
5
3 7
5 4
4 4
9 4
9 9
5
5 4
5 9
5 5
4 3
1 0
5
3 2
1 2
7 2
6 2
5 2
6
7 2
7 9
0 3
8 8
4 4
3 8
6
2 8
2 5
3 5
3 8
2 0
0 2
6
2 3
8 4
2 9
2 2
2 6
4 9
6
2 1
7 6
6 5
...

output:

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

result:

wrong answer 12th lines differ - expected: '5', found: '2'