QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#21734 | #2838. 2D Geometry | WhybullYMe# | RE | 0ms | 3676kb | C++14 | 1004b | 2022-03-08 14:44:14 | 2022-05-08 04:00:22 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define ri int
typedef long long ll;
const int maxn=2e5+10;
template<class T>inline bool ckmin(T &x,const T &y){return x>y?x=y,1:0;}
template<class T>inline bool ckmax(T &x,const T &y){return x<y?x=y,1:0;}
template<class T>inline void clear(T *arr,int siz,int val=0){memset(arr,val,sizeof(T)*(siz+1));}
int n;
int main(){
while(~scanf("%d",&n)){
int ans=0;
typedef pair<int,int> pii;
#define fi first
#define se second
vector<vector<pii>>v;
for(ri i=1;i<=n;++i){
pii p;
scanf("%d%d",&p.fi,&p.se);
for(auto &j:v){
auto intersect=[&](pii x,pii y,pii z){
return abs(1ll*(y.se-x.se)*(z.fi-y.fi))==abs(1ll*(z.se-y.se)*(y.fi-x.fi));
};
if(j.size()==1){j.push_back(p);goto skip;}
else if(intersect(j[j.size()-2],j[j.size()-1],p)){j.push_back(p);goto skip;}
else{ans+=3,j.pop_back(),j.pop_back();goto skip;}
}
v.push_back({p});
skip:;
}
printf("%d\n",n-ans);
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3676kb
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
Dangerous Syscalls
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 ...