//#define _GLIBCXX_DEBUG #include #define rep(i, n) for(int i=0; i; using vs = vector; using vi = vector; using vvi = vector; template using PQ = priority_queue; template using PQG = priority_queue, greater >; const int INF = 0xccccccc; const ll LINF = 0xcccccccccccccccLL; template inline bool chmax(T1 &a, T2 b) {return a < b && (a = b, true);} template inline bool chmin(T1 &a, T2 b) {return a > b && (a = b, true);} template istream &operator>>(istream &is, pair &p) { return is >> p.first >> p.second;} template ostream &operator<<(ostream &os, const pair &p) { return os << p.first << ' ' << p.second;} #define N 1001000 //head int n; float p, q, r; char s[N]; pair Random(int); pair dfs(int, float); pair calc(int); int check(int i) { if(s[i] == 'N') return 0; if(s[i] == 'Y') return 1; if(s[i] == 'r') return -1; if(s[i] == '(') return 99; if(s[i] == ')') return 100; return INF; } int main() { scanf("%d%f%f%f %s", &n, &p, &q, &r, s); printf("%d\n", int(calc(0).first*100)); } pair Random(int i) { i += 7; auto [u1, v1] = calc(i); auto [u2, v2] = calc(v1); return {u1*u2*p + (1-u1*u2)*q, v2+1}; } pair dfs(int i, float p) { if(i == n or check(i) != INF) return {p, i}; if(s[i] == 'o') { auto [u, v] = calc(i+2); p = 1-p; u = 1-u; p *= u; u = 1-p; return {u*(1-r)+p*r, v}; } int z = check(i += 3); if(z == 0) return dfs(i+2, r); if(z == 1) return dfs(i+3, p*(1-r)+(1-p)*r); if(z == -1) { auto [u, v] = Random(i); u *= p; p = 1-u; return dfs(v, u*(1-r)+p*r); } auto [u, v] = calc(i+1); u *= p; p = 1-u; return dfs(v+1, u*(1-r)+p*r); } pair calc(int i) { int u = check(i); if(u == -1) { auto [u, v] = Random(i); return dfs(v, u); } if(u == 0) return dfs(i+2, 0); if(u == 1) return dfs(i+3, 1); auto [z, v] = calc(i+1); return dfs(v+1, z); }