topic
analysis
- First of all, we certainly want to enumerate twenty-two
- Then, we need to know the slope
- In the coordinate system a linear function y = kx k is the slope
- Quadratic function is y = kx + bk slope
- Because both sides of a right triangle slope multiplied by -1
- With this property, we can see that the slope of the triangular configuration but equal in the different quadrants of point
- So we ask the same slope point
- Then we can have a sort to optimize
- With the same constant slope
- The answer is to speak the same slope adjacent two quadrants of the dot and then summed up
Code
1 #include<iostream> 2 #include<algorithm> 3 using namespace std; 4 long long x[10010],y[10001]; 5 struct sb 6 { 7 long long x,y,xx; 8 }tmp[10001]; 9 void turn(int p) 10 { 11 swap(tmp[p].x,tmp[p].y); 12 tmp[p].y=-tmp[p].y; 13 tmp[p].xx=(tmp[p].xx+1)%4; 14 } 15 bool cmp(sb a,sb b) 16 { 17 return a.x*b.y>b.x*a.y; 18 } 19 int cnt; 20 int main () 21 { 22 int n; 23 cin>>n; 24 for (int i=1;i<=n;i++) cin>>x[i]>>y[i]; 25 for (int i=1;i<=n;i++) 26 { 27 for (int j=1;j<=n;j++) 28 { 29 tmp[j].x=x[j]-x[i]; 30 tmp[j].y=y[j]-y[i]; 31 tmp[j].xx=0; 32 if (i==j) 33 { 34 tmp[j].x=tmp[1].x; 35 tmp[j].y=tmp[1].y; 36 tmp[j].xx=tmp[1].xx; 37 } 38 else 39 while (tmp[j].x<=0||tmp[j].y<0) turn(j); 40 } 41 sort(tmp+2,tmp+n+1,cmp); 42 int j=2; 43 while (j<=n) 44 { 45 int ans[4]={0}; 46 int k=j; 47 while (k<=n&&tmp[j].x*tmp[k].y==tmp[k].x*tmp[j].y) 48 ans[tmp[k].xx]++,k++; 49 for (int kk=0; kk <= 3 ; kk ++ ) 50 cnt + = years [kk] * years [(kk + 1 )% 4 ]; 51 j = k; 52 } 53 } 54 cout << cnt; 55 }