# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
72310 |
2018-08-26T07:00:42 Z |
team(#2159, comfile) |
Dstorv (FXCUP3_dstorv) |
C++17 |
|
3 ms |
560 KB |
#include <bits/stdc++.h>
#define M 1000000007
using namespace std;
typedef long long ll;
ll n,r,h,A,b;
string s;
int a[5010];
vector<int> v;
ll pw(ll x,ll y){
ll tmp=1;
while(y){
if(y%2) tmp=tmp*x%M;
y /= 2;
x=x*x%M;
}
return tmp;
}
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
int main(){
ios_base::sync_with_stdio(0);cin.tie(0);
cin>>n>>r>>h;cin>>s;cin>>A>>b;
ll tmp=gcd(r,h); r/=tmp; h/= tmp;
int tot=0;
for(int i=0;i<n;i++){
if(s[i]=='R') a[i]=1;
else a[i]=2,tot++;
}
for(int i=0;i<n;i++) v.push_back(a[i]);
int cnt=0;
for(int i=0;i<n;i++){
for(int j=0;j<v.size()-1;j++) if(a[j]==1 && a[j+1]==2){
a[j]=0; a[j+1]=1; cnt++;
}
for(int j=v.size();j<n;j++) a[j]=0;v.clear();
for(int j=0;j<n;j++) if(a[j]) v.push_back(a[j]);
for(int j=0;j<v.size();j++) a[j]=v[j];
}
if(cnt>=tot && A==(n-tot)) cout<<pw(pw(r+h,cnt),M-2)*pw(h,cnt)%M<<'\n';
else cout<<"0"<<'\n';
return 0;
}
Compilation message
dstorv.cpp: In function 'int main()':
dstorv.cpp:31:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int j=0;j<v.size()-1;j++) if(a[j]==1 && a[j+1]==2){
~^~~~~~~~~~~
dstorv.cpp:34:9: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
for(int j=v.size();j<n;j++) a[j]=0;v.clear();
^~~
dstorv.cpp:34:44: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
for(int j=v.size();j<n;j++) a[j]=0;v.clear();
^
dstorv.cpp:36:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int j=0;j<v.size();j++) a[j]=v[j];
~^~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
3 ms |
360 KB |
Output is correct |
3 |
Incorrect |
3 ms |
560 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
560 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
3 ms |
360 KB |
Output is correct |
3 |
Incorrect |
3 ms |
560 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |