# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
72349 | 2018-08-26T07:22:11 Z | BOJ 8481(#2179, veydpz, jh05013, 16silver) | Dstorv (FXCUP3_dstorv) | C++17 | 2 ms | 484 KB |
#include <cstdio> char s[7777]; char st[7777]; int top, idx; const long long P=1000000007LL; long long N,r,h,A,B; long long ans,ansans; long long llpow(long long x, long long n){ if(n==1) return x; long long h=llpow(x,n/2); if(n&1) return ((h*h)%P*x)%P; return (h*h)%P; } long long invrh; void push(char c){ st[++top]=c; } int main(){ scanf("%lld%lld%lld",&N,&r,&h); scanf("%s",s); scanf("%lld%lld",&A,&B); invrh=llpow(r+h,P-2); ans=1LL; for(int i=0;i<A;i++){ ans=((ans*h)%P*invrh)%P; } for(int i=0;i<B;i++){ ans=((ans*r)%P*invrh)%P; } if(N<=15){ if(A+B>N) printf("0"); else{ ansans=0LL; for(int i=0;i<(1<<N-A-B);i++){ top=-1; idx=0; for(int j=0;j<N-A-B;j++){ while(idx < N){ push(s[idx]); idx++; if(top > 0 && st[top]=='H' && st[top-1]=='R') break; } if(i&(1<<j)){ top--; } else{ top--; st[top]='H'; } } for(;idx<N;idx++) push(s[idx]); if(top==A+B-1){ int k; for(k=0;k<B;k++){ if(st[k]!='H') break; } if(k==B){ for(k=0;k<A;k++){ if(st[B+k]!='R') break; } if(k==A) ansans++; } } } ans=(ans*ansans)%P; printf("%lld",ans); } } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 376 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 484 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 376 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |