Submission #1041415

# Submission time Handle Problem Language Result Execution time Memory
1041415 2024-08-02T03:31:32 Z vjudge1 Ljetopica (COI19_ljetopica) C++17
0 / 100
0 ms 348 KB
//~~~~~~~~~~~~~MJ®™~~~~~~~~~~~~~
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#define rep1(n) for(ll i=0; i<(ll)(n); ++i)
#define rep2(i,n) for(ll i=0; i<(ll)(n); ++i)
#define rep3(i,a,b) for(ll i=(ll)(a); i<(ll)(b); ++i)
#define rep4(i,a,b,c) for(ll i=(ll)(a); i<(ll)(b); i+=(c))
#define cut4(a,b,c,d,e,...) e
#define rep(...) cut4(__VA_ARGS__,rep4,rep3,rep2,rep1)(__VA_ARGS__)
#define per1(n) for(ll i=((ll)n)-1; i>=0; --i)
#define per2(i,n) for(ll i=((ll)n)-1; i>=0; --i)
#define per3(i,a,b) for(ll i=((ll)a)-1; i>=(ll)(b); --i)
#define per4(i,a,b,c) for(ll i=((ll)a)-1; i>=(ll)(b); i-=(c))
#define per(...) cut4(__VA_ARGS__,per4,per3,per2,per1)(__VA_ARGS__)
#define ll long long
#define ln cout<<endl
#define int long long
#define Code ios_base::sync_with_stdio(0);
#define by cin.tie(NULL);
#define Hayan cout.tie(NULL);
#define append push_back
#define all(x) (x).begin(),(x).end()
#define allr(x) (x).rbegin(),(x).rend()
#define vi vector<int>
#define yes cout<<"YES"<<endl;
#define no cout<<"NO"<<endl;
#define vb vector<bool>
#define vv vector<vi>
#define vp vector<pi>
#define vs vector<string>
#define ul map<int,vi>
// #define ub map<int,bool>
#define ui map<int,int>
#define sum(a) accumulate(all(a),0)
#define add insert
#define endl '\n' 
#define pi pair<int,int>
#define ff first
#define ss second
using namespace std;
const int mod=1e9+7;
int to_int(string &a)
{
    int ans=0;
    int mask=1;
    per(a.size())
    {
        ans+=(a[i]-'0')*mask;
        // cout<<ans<<endl;
        mask<<=1;
    }
    return ans;
}
void solve()
{
    int n,k,e,m,ans=0;
    cin>>n>>k;
    string s,b1,b2,s1,s2;
    cin>>s>>b1>>b2;
    int lb=to_int(b1);
    int ub=to_int(b2);
    s1+='1';
    s2+='1';
    // cout<<lb<<" "<<ub;ln;
    
    int ans1=1,ans2=1;
    vi a(n);
    rep(n-1)
    {
        ans1<<=1;
      if (s[i]=='R')
        ans1++;
        ans1%=mod;
    }
    per(n-1)
    {
        ans2<<=1;
      if (s[i]=='R')
      ans2++;
        ans2%=mod;
    }

    // cout<<ans1<<" "<<ans2<<endl;
    if (ans1>=lb and ans1<=ub)
    {
        ans+=ans1;
        ans%=mod;
    }
    if (ans2>=lb and ans2<=ub)
    {
        ans+=ans2;
        ans%=mod;
    }
    //vi a;
    // //rep(n){cin>>e;a.append(e);}
    




    cout<<ans%mod;
    // cout<<a.size();
    // for (auto i: a){cout<<i<<" ";}
}
signed main(){
    Code by Hayan
    int ans=1;
    //cout<<setprecision(1000);
    // cin>>ans;
    while(ans--){
        // cout << "Case #" << ans << ": \n";
        solve();ln;}}

Compilation message

ljetopica.cpp: In function 'void solve()':
ljetopica.cpp:73:7: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   73 |       if (s[i]=='R')
      |       ^~
ljetopica.cpp:75:9: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   75 |         ans1%=mod;
      |         ^~~~
ljetopica.cpp:58:13: warning: unused variable 'e' [-Wunused-variable]
   58 |     int n,k,e,m,ans=0;
      |             ^
ljetopica.cpp:58:15: warning: unused variable 'm' [-Wunused-variable]
   58 |     int n,k,e,m,ans=0;
      |               ^
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -