fork download
  1. #include<bits/stdc++.h>
  2. #pragma GCC optimize("Ofast")
  3. using namespace std;
  4. // author : buddy (tu luong)
  5. //------------------------------
  6. #define fo(i,a,b) for(int i=a;i<=b;++i)
  7. #define fo1(i,a,b) for (int i=a;i<b;++i)
  8. #define N 2001
  9. #define INF 100001
  10. #define fi first
  11. #define se second
  12. #define fast_IO ios_base::sync_with_stdio(false); cin.tie(NULL);
  13. #define pb push_back
  14. #define mp make_pair
  15. #define double int
  16. struct point
  17. {
  18. double x,y;
  19. point(double _x=0, double _y=0)
  20. {
  21. x=_x;
  22. y=_y;
  23. }
  24. /* bool operator <(const point &tmp) const
  25.   {
  26.   return(x<tmp.x);
  27.   } */
  28. };
  29. bool cmp( point &a1, point &b1)
  30. {
  31. return(a1.x<b1.x);
  32. }
  33. double kt( point a1, point a2, point a3 )
  34. {
  35. double tmp = a1.x * (a2.y - a3.y);
  36. double tmp1= a2.x * (a3.y - a1.y);
  37. double tmp2=a3.x * (a1.y - a2.y);
  38. double s=tmp+tmp1+tmp2 ;
  39. return(s);
  40. }
  41. /*bool kt(const point &a,const point &b)
  42. {
  43.  
  44. } */
  45. int n,ans=0;
  46. point a[N];
  47. int main()
  48. {
  49. // fast_IO
  50. cin>>n;
  51. fo(i,1,n)
  52. {
  53. cin>>a[i].x>>a[i].y;
  54. }
  55. sort(a+1,a+1+n,cmp);
  56. /* fo(i,1,n)
  57.   c[i][1]=i;
  58.   //fo(i,1,3)
  59.   //c[0][i]=1;
  60.   fo(i,1,n)
  61.   fo(j,2,3)
  62.   c[i][j]=c[i-1][j-1]+c[i-1][j]; */
  63. for (int i=1;i<=n-2;++i)
  64. {
  65.  
  66. int j=i,cnt=0;
  67. while (a[j].x==a[j+1].x && a[j].x==a[j+2].x)
  68. {
  69. ++cnt;
  70. ++j;
  71. }
  72. for (int i1=1;i1<=cnt;++i1) ans+=i1;
  73. //if (i==1|| a[i-1].x!=a[i].x) ans+=c[j-i][3];
  74. //if (c[j-1][3]!=0) cout<<c[j-1][3]<<endl;
  75. for (int i2=j+1;i2<=n-1;++i2)
  76. for (int i3=i2+1;i3<=n;++i3)
  77. if (kt(a[i],a[i2],a[i3])==0)
  78. ++ans; //cout<<i1<<' '<<i2<<' '<<i3<<endl; }
  79. }
  80. cout<<ans;
  81. // cout<<c[3][3];
  82.  
  83. }
  84.  
Success #stdin #stdout 0.01s 5272KB
stdin
Standard input is empty
stdout
Standard output is empty