Submission #72287

#TimeUsernameProblemLanguageResultExecution timeMemory
72287team (#118)Dstorv (FXCUP3_dstorv)C++17
0 / 100
3 ms640 KiB
#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 (stderr)

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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...