fork download
  1. #include<bits/stdc++.h>
  2. #define f first
  3. #define int long long
  4. #define s second
  5. using namespace std;
  6. const int N=45,mod=1e9+7;
  7. int t,x[N],y[N],n,dp[N][N][N][N],fact[N],
  8. ans,ifact[N],A[N][N];
  9. string s;
  10. vector<int>inside[N][N][N];
  11. vector<pair<int,pair<int,pair<int,int> > > > triangles;
  12. int find_area(int X1,int Y1,int X2,int Y2){
  13. return abs(X1*Y2-Y1*X2);
  14. }
  15. bool is_inside(int i,int j,int k,int p){
  16. int X1=x[i],Y1=y[i],X2=x[j],Y2=y[j],X3=x[k],Y3=y[k],X4=x[p],Y4=y[p];
  17. if(find_area(X2-X1,Y2-Y1,X3-X1,Y3-Y1) == find_area(X2-X1,Y2-Y1,X4-X1,Y4-Y1)
  18. + find_area(X3-X1,Y3-Y1,X4-X1,Y4-Y1)
  19. + find_area(X3-X2,Y3-Y2,X4-X2,Y4-Y2) ) return 1;
  20. return 0;
  21. }
  22. void update(int a1,int a2,int a3,int c) {
  23. int all=inside[a1][a2][a3].size();
  24. int A1=min(a1,min(a2,a3)),A3=max(a1,max(a2,a3)),A2=a1+a2+a3-A1-A3;
  25. int B1=min(a1,min(a2,c)),B3=max(a1,max(a2,c)),B2=a1+a2+c-B1-B3;
  26. for(int i=0;i<=inside[B1][B2][B3].size();i++){
  27. dp[A1][A2][A3][i+1]+=dp[B1][B2][B3][i];
  28. dp[A1][A2][A3][i+1]%=mod;
  29. }
  30. }
  31. int pwr(int u,int v){
  32. if(v==0) return 1;
  33. if(v==1) return u;
  34. if(v%2) return u*pwr(u,v-1)%mod;
  35. int p=pwr(u,v/2);
  36. return p*p%mod;
  37. }
  38. main(){
  39. cin>>n;
  40. for(int i=1;i<=n;i++){
  41. cin>>x[i]>>y[i];
  42. }
  43. fact[0]=ifact[0]=1;
  44. for(int i=1;i<=n;i++){
  45. fact[i] = fact[i-1] * i%mod;
  46. ifact[i] = ifact[i-1]*pwr(i,mod-2)%mod;
  47. }
  48. for(int i=1;i<=n;i++){
  49. for(int j=i;j<=n;j++){
  50. A[i][j] = fact[j]*ifact[j-i]%mod;
  51. }
  52. }
  53. for(int i=1;i<=n;i++){
  54. for(int j=1;j<=n;j++){
  55. for(int k=1;k<=n;k++){
  56. for(int p=1;p<=n;p++){
  57. if(is_inside(i,j,k,p)) inside[i][j][k].push_back(p);
  58. }
  59. if(i<j && j<k)triangles.push_back({inside[i][j][k].size(),{i,{j,k}}});
  60. }
  61. }
  62. }
  63. sort(triangles.begin(),triangles.end());
  64. for(int k=0;k<triangles.size();k++) {
  65. int a1=triangles[k].s.f,a2=triangles[k].s.s.f,a3=triangles[k].s.s.s;
  66. dp[a1][a2][a3][3]=1;
  67. for(int j=0;j<inside[a1][a2][a3].size();j++){
  68. int p = inside[a1][a2][a3][j];
  69. if(a1==p || a2==p || a3==p) continue;
  70. update(a1,a2,a3,p);
  71. update(a1,a3,a2,p);
  72. update(a2,a3,a1,p);
  73. }
  74. int all=inside[a1][a2][a3].size();
  75. vector<int> new_dp(n+5);
  76. for(int i=3;i<=all;i++){
  77. new_dp[i]+=dp[a1][a2][a3][i]; new_dp[i]%=mod;
  78. for(int j=i+1;j<=all;j++){
  79. // # of ways of choosing j-i from all-i A(j-i,all-i)
  80. new_dp[j]+=dp[a1][a2][a3][i]*A[j-i][all-i]%mod;
  81. new_dp[j]%=mod;
  82. }
  83. }
  84. for(int i=0;i<=all;i++){
  85. dp[a1][a2][a3][i] = new_dp[i];
  86. }
  87. ans+=dp[a1][a2][a3][n]*6%mod;
  88. ans%=mod;
  89. }
  90. cout<<ans;
  91. }
  92.  
Success #stdin #stdout 0.01s 6176KB
stdin
Standard input is empty
stdout
Standard output is empty