Submission #72295

# Submission time Handle Problem Language Result Execution time Memory
72295 2018-08-26T06:53:47 Z team(#2159, comfile) Dstorv (FXCUP3_dstorv) C++17
0 / 100
4 ms 456 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) 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 3 ms 248 KB Output is correct
2 Correct 4 ms 364 KB Output is correct
3 Incorrect 3 ms 440 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 456 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 248 KB Output is correct
2 Correct 4 ms 364 KB Output is correct
3 Incorrect 3 ms 440 KB Output isn't correct
4 Halted 0 ms 0 KB -