QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#196104 | #2838. 2D Geometry | CSU2023# | WA | 2ms | 9932kb | C++14 | 1.2kb | 2023-10-01 12:29:04 | 2023-10-01 12:29:05 |
Judging History
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: ''