Advertisement
turmax

Untitled

Jan 7th, 2021
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.03 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4. #define int long long
  5. //#define double long double
  6. typedef pair <double,double> cd;
  7. pair <double,double> operator +(pair <double,double> u,pair <double,double> v)
  8. {
  9. return {u.first+v.first,u.second+v.second};
  10. }
  11. pair <double,double> operator *(pair <double,double> u,pair <double,double> v)
  12. {
  13. return {u.first*v.first-u.second*v.second,u.second*v.first+v.second*u.first};
  14. }
  15. pair <double,double> operator -(pair <double,double> u,pair <double,double> v)
  16. {
  17. return {u.first-v.first,u.second-v.second};
  18. }
  19. pair <double,double> operator /(pair <double,double> u,pair <double,double> v)
  20. {
  21. return {(u.first*v.first+u.second*v.second)/(v.first*v.first+v.second*v.second),(u.second*v.first-v.second*u.first)/(v.first*v.first+v.second*v.second)};
  22. }
  23. vector <vector <cd> > a;
  24. vector <pair<int,int> > z1,z2;
  25. vector <cd> operator *(vector <cd> v,cd x)
  26. {
  27. for(int i=0;i<v.size();++i) v[i]=(v[i]*x);
  28. return v;
  29. }
  30. vector <cd> operator -(vector <cd> v1,vector <cd> v2)
  31. {
  32. for(int i=0;i<v1.size();++i) v1[i]=(v1[i]-v2[i]);
  33. return v1;
  34. }
  35. int l;
  36. bool cmp(vector <cd> &a,vector <cd> &b)
  37. {
  38. return abs(a[l].first)+abs(a[l].second)<abs(b[l].first)+abs(b[l].second);
  39. }
  40. void det1()
  41. {
  42. //cout<<a[l][l].first<<' '<<a[l][l].second<<" a[l][l] "<<endl;
  43. if(l==a.size()) return;
  44. sort(a.begin()+l,a.end(),cmp);reverse(a.begin()+l,a.end());
  45. //cout<<a[l][l].first<<' '<<a[l][l].second<<" a[l][l] "<<endl;
  46. for(int i=(l+1);i<a.size();++i)
  47. {
  48. cd z=(a[i][l]/a[l][l]);
  49. a[i]=(a[i]-(a[l]*z));
  50. }
  51. ++l;
  52. det1();
  53. }
  54. cd det()
  55. {
  56. l=0;
  57. det1();
  58. cd ans={1,0};
  59. for(int i=0;i<a.size();++i) ans=(ans*a[i][i]);
  60. return ans;
  61. }
  62. int32_t main()
  63. {
  64. ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
  65. int n=4;int m=18;
  66. vector <pair<int,int> > v;
  67. char b[n][m];
  68. int u;
  69. for(int i=0;i<n;++i)
  70. {
  71. string s;
  72. cin>>s;
  73. for(int j=0;j<m;++j)
  74. {
  75. b[i][j]=s[j];
  76. if(s[j]=='*')
  77. {
  78. v.push_back({i,j});
  79. }
  80. }
  81. }
  82. u=v.size();
  83. int h=(u/2);
  84. //cout<<h<<" h "<<endl;
  85. for(int i=0;i<h;++i) {vector <cd> v;v.resize(h);a.push_back(v);}
  86. for(int i=0;i<h;++i) for(int j=0;j<h;++j) a[i][j]=cd(0,0);
  87. for(auto l:v) {if((l.first+l.second)%2==0) z1.push_back(l);else z2.push_back(l);}
  88. for(int i=0;i<z1.size();++i)
  89. {
  90. for(int j=0;j<z2.size();++j)
  91. {
  92. auto h1=z1[i];
  93. auto h2=z2[j];
  94. if(h1.second==h2.second && abs(h1.first-h2.first)==1) a[i][j]=cd(1,0);
  95. if(h1.first==h2.first && abs(h1.second-h2.second)==1) a[i][j]=cd(0,1);
  96. }
  97. }
  98. //for(int i=0;i<u;++i) {for(int j=0;j<u;++j) cout<<a[i][j].first<<a[i][j].second<<' ';cout<<endl;}
  99. cd ans=det();
  100. cout<<setprecision(40)<<ans.first<<' '<<ans.second<<endl;
  101. return 0;
  102. }
  103. /*
  104. input:
  105. ***..***..***..***
  106. ******.****.******
  107. ...***.****.***...
  108. .....***..***.....
  109. */
  110.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement