Submission #72287

# Submission time Handle Problem Language Result Execution time Memory
72287 2018-08-26T06:49:40 Z team(#2159, comfile) Dstorv (FXCUP3_dstorv) C++17
0 / 100
3 ms 640 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;
    for(int i=0;i<n;i++){
        if(s[i]=='R') a[i]=1;
        else a[i]=2;
    }
    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];
    }
    cout<<pw(pw(r+h,cnt),M-2)*pw(h,cnt)%M<<'\n';;
    return 0;
}

Compilation message

dstorv.cpp: In function 'int main()':
dstorv.cpp:30: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:33: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:33: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:35: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 2 ms 356 KB Output is correct
3 Correct 2 ms 596 KB Output is correct
4 Correct 3 ms 596 KB Output is correct
5 Incorrect 3 ms 596 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 640 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 2 ms 356 KB Output is correct
3 Correct 2 ms 596 KB Output is correct
4 Correct 3 ms 596 KB Output is correct
5 Incorrect 3 ms 596 KB Output isn't correct
6 Halted 0 ms 0 KB -