1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
#include<bits/stdc++.h>
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("trapv")

#define st first
#define nd second
#define pb(x) push_back(x)
#define pp(x) pop_back(x)
#define mp(a, b) make_pair(a, b)
#define all(x) (x).begin(), (x).end()
#define rev(x) reverse(all(x))
#define sor(x) sort(all(x))
#define sz(x) (int)(x).size()
#define rsz(x) resize(x)

using namespace std;

///~~~~~~~~~~~~~~~~~~~~~~~~~~

void debug(){cerr<<"\n";}
template <typename H, typename... T>
void debug(H h, T... t) {cerr<<h; if (sizeof...(t)) cerr << ", "; debug(t...);}
#define deb(x...) cerr<<#x<<" = ";debug(x);

///~~~~~~~~~~~~~~~~~~~~~~~~~

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<pii > vii;
typedef vector<ll> vl;
typedef vector<pll> vll;
typedef string str;

#define BOOST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());

const int N=1<<19, INF=1e9+5, mod=1e9+7;
int n1[N], n3[N];
int tab[N+N];
int quer(int v, int c){
	v+=N;
	//cout<<v-N<<" "<<c<<"\n";
	while(v>=1){
		if((v&1)==0 && tab[v+1]>=c){
			v++;
			while(v<N){
				if(tab[2*v]>=c)v=2*v;
				else v=2*v+1;
			}
			return v-N;
		}
		v/=2;
	}
	assert(false);
	return 0;
}
int main(){
	const ld EPS=-1e-9;
	BOOST;
	int n;
	ld v1, v2, v3;
	ld v0;
	cin>>n>>v0>>v1>>v2>>v3;
	string s[4];
	cin>>s[1]>>s[2]>>s[3];
	s[3][0]='.';
	/*for(int i=0; i<=18; i++){
		cout<<i<<"\n";
		for(int j=0; j<3; j++)cout<<string(i*(2-j), '.')<<s[j+1]<<"\n";
		cout<<"\n";
	}*/
	for(int i=0; i<3; i++)s[i].pb('.');
	n1[n]=n3[n]=INF;
	for(int i=n-1; i>=0; i--){
		if(s[3][i]=='.')n3[i]=n3[i+1]+1;
		else n3[i]=-1;
	}
	for(int i=0; i<=n; i++){
		tab[N+i+1]=n3[i];
	}
	for(int i=N-1; i>0; i--){
		tab[i]=max(tab[2*i+1], tab[2*i]);
	}
	for(int i=n-1; i>=0; i--){
		if(s[1][i]=='.')n1[i]=n1[i+1];
		else n1[i]=i-1;
	}
	for(int i=0; i<n; i++){
		if(s[1][i]=='#')n1[i]=n1[i-1];
	}
	int lst[4]={-1, -1, -1, -1};
	for(int i=0; i<n; i++){
		for(int j=1; j<=3; j++)if(s[j][i]=='#')lst[j]=i;
	}
	ld t=0;
	int prv=0;
	for(int i=1; i<=lst[2]+1; i++){
		if(s[2][i]!='.')continue;
		ld pos=prv+v2*t;
		//deb(prv, t);

		ld t2=t+(i-prv)/(v0-v2);
		int id1=n1[min(int(-EPS+pos-v1*t), n)];
		ld t1=(id1-i)/(v2-v1);
		//deb(t1, t2, id1, pos, pos-v1*t, EPS+floor(EPS+pos-v1*t));

		ld wym=(i-prv)/(v0-v2)*(v0-v3);
		ld pos2=pos-v3*t;
		int id=floor(pos2);
		//deb(wym, pos2, id, t1, n3[id], n3[id]+id-wym-pos2);
		if(id>=n || (n3[id]+id-wym-pos2>=EPS))t1=min(t1, t2);
		else{
			id=ceil(pos2);
			//id++;
			//while((ld)n3[id]<wym)id++;
			id=quer(id, int(ceil(wym)-EPS))-1;
			//deb(id);
			t1=min(t1, (id-prv)/(v2-v3)+t2-t);
		}
		//deb(wym, pos2, id, t1);

		if(prv+1!=i)t=max(t2, t1);
		else t=t2;
		prv=i;
		//deb();
	}
	//deb(t);
	ld pos=lst[2]+1+v2*t-v0*t;
	//deb(pos, lst[1], lst[3]);
	//deb(lst[1]+t);
	t=max(t, (lst[1]+1-pos)/(v0-v1));
	t=max(t, (lst[3]+1-pos)/(v0-v3));
	//ld ans;
	//cin>>ans;
	//assert((t-ans)<1e-10);
	//t=ans;
	//if(n>=16)t=ans;
	cout<<fixed<<setprecision(15)<<t<<"\n";
	//for(int i=0; i<n; i++)
}