Submission #1041659

# Submission time Handle Problem Language Result Execution time Memory
1041659 2024-08-02T06:50:04 Z vjudge1 Ljetopica (COI19_ljetopica) C++17
0 / 100
0 ms 348 KB
#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")
using namespace std;
#define int long long 
const int N = 100001;
const int mod = 1e9+7;
const int mod1 = 998244353;
bool valid(string a,string b,string c){
    if(a<=c and c<=b)return true;
    return false;
}
void solve(){
    int n,k;cin >>n >> k;
    string s;cin >> s;
    string a;cin >> a;
    string b;cin >> b;
    int ss = 0;
    if(k == 0){
        int ans = 1;string c="1";
        for(int i = 0;i<s.size() ; i++){
            if(s[i] == 'L'){
                ans *= 2;ans%=mod;
                c.push_back('0');
            }
            else{
                ans *= 2;ans++;ans%=mod;
                c.push_back('1');
            }
        }
        if(valid(a,b,c)){ss+=ans;}
        ss = ss % mod;
        ans = 1;c = "1";
        for(int i = s.size()-1;i>=0 ;i --){
            if(s[i] == 'L'){
                ans *= 2;ans%=mod;
                c.push_back('0');
            }
            else{
                ans *= 2;ans ++ ;ans%=mod;
                c.push_back('1');
            }
        }
        if(valid(a,b,c))ss+=ans;
        ss%=mod;

    }
    cout<<ss<<endl;
}
signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);cout.tie(NULL);
    
    int t=1;
    // cin>>t;
    cout<<setprecision(16);
    while(t--){
        solve();
    }
}

Compilation message

ljetopica.cpp: In function 'void solve()':
ljetopica.cpp:22:24: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |         for(int i = 0;i<s.size() ; i++){
      |                       ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 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 344 KB Output isn't correct
2 Halted 0 ms 0 KB -