Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define int long long
- //#define double long double
- typedef pair <double,double> cd;
- pair <double,double> operator +(pair <double,double> u,pair <double,double> v)
- {
- return {u.first+v.first,u.second+v.second};
- }
- pair <double,double> operator *(pair <double,double> u,pair <double,double> v)
- {
- return {u.first*v.first-u.second*v.second,u.second*v.first+v.second*u.first};
- }
- pair <double,double> operator -(pair <double,double> u,pair <double,double> v)
- {
- return {u.first-v.first,u.second-v.second};
- }
- pair <double,double> operator /(pair <double,double> u,pair <double,double> v)
- {
- 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)};
- }
- vector <vector <cd> > a;
- vector <pair<int,int> > z1,z2;
- vector <cd> operator *(vector <cd> v,cd x)
- {
- for(int i=0;i<v.size();++i) v[i]=(v[i]*x);
- return v;
- }
- vector <cd> operator -(vector <cd> v1,vector <cd> v2)
- {
- for(int i=0;i<v1.size();++i) v1[i]=(v1[i]-v2[i]);
- return v1;
- }
- int l;
- bool cmp(vector <cd> &a,vector <cd> &b)
- {
- return abs(a[l].first)+abs(a[l].second)<abs(b[l].first)+abs(b[l].second);
- }
- void det1()
- {
- //cout<<a[l][l].first<<' '<<a[l][l].second<<" a[l][l] "<<endl;
- if(l==a.size()) return;
- sort(a.begin()+l,a.end(),cmp);reverse(a.begin()+l,a.end());
- //cout<<a[l][l].first<<' '<<a[l][l].second<<" a[l][l] "<<endl;
- for(int i=(l+1);i<a.size();++i)
- {
- cd z=(a[i][l]/a[l][l]);
- a[i]=(a[i]-(a[l]*z));
- }
- ++l;
- det1();
- }
- cd det()
- {
- l=0;
- det1();
- cd ans={1,0};
- for(int i=0;i<a.size();++i) ans=(ans*a[i][i]);
- return ans;
- }
- int32_t main()
- {
- ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
- int n=4;int m=18;
- vector <pair<int,int> > v;
- char b[n][m];
- int u;
- for(int i=0;i<n;++i)
- {
- string s;
- cin>>s;
- for(int j=0;j<m;++j)
- {
- b[i][j]=s[j];
- if(s[j]=='*')
- {
- v.push_back({i,j});
- }
- }
- }
- u=v.size();
- int h=(u/2);
- //cout<<h<<" h "<<endl;
- for(int i=0;i<h;++i) {vector <cd> v;v.resize(h);a.push_back(v);}
- for(int i=0;i<h;++i) for(int j=0;j<h;++j) a[i][j]=cd(0,0);
- for(auto l:v) {if((l.first+l.second)%2==0) z1.push_back(l);else z2.push_back(l);}
- for(int i=0;i<z1.size();++i)
- {
- for(int j=0;j<z2.size();++j)
- {
- auto h1=z1[i];
- auto h2=z2[j];
- if(h1.second==h2.second && abs(h1.first-h2.first)==1) a[i][j]=cd(1,0);
- if(h1.first==h2.first && abs(h1.second-h2.second)==1) a[i][j]=cd(0,1);
- }
- }
- //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;}
- cd ans=det();
- cout<<setprecision(40)<<ans.first<<' '<<ans.second<<endl;
- return 0;
- }
- /*
- input:
- ***..***..***..***
- ******.****.******
- ...***.****.***...
- .....***..***.....
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement