Submission #233359

#TimeUsernameProblemLanguageResultExecution timeMemory
233359VimmerLjetopica (COI19_ljetopica)C++14
0 / 100
5 ms384 KiB
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("-O3")
//#pragma GCC optimize("Ofast")

#define sz(x) ll(x.size())
#define base 1000000
#define M ll(1e9+7)
#define F first
#define S second
#define pb push_back
#define in insert
#define eb emplace_back
#define ed "\n"

using namespace std;
//using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef short int si;

//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;





int main()
{
//    freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);

    ios_base::sync_with_stdio(0); istream::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    ll n, k;

    cin >> n >> k;

    ll a = 0, b = 0;

    string s;

    cin >> s;

    string t;

    cin >> t;

    for (ll i = 0; i < sz(t); i++)
    {
        if (t[i] == '1') {a *= 2; a++;}
          else a *= 2;
    }

    cin >> t;

    for (ll i = 0; i < sz(t); i++)
    {
        if (t[i] == '1') {b *= 2; b++;}
          else b *= 2;
    }

    ll pos1 = 1, pos2 = 1;

    for (ll i = 0; i < sz(s); i++)
    {
        if (s[i] == 'L')
        {
            pos1 *= 2;

            pos2 *= 2;

            pos2++;
        }
        else
        {
            pos1 *= 2;

            pos1++;

            pos2 *= 2;
        }
    }

    ll ans = 0;

    if (a <= pos1 && pos1 <= b) ans += pos1;

    if (a <= pos2 && pos2 <= b) ans += pos2;

    cout << ans << endl;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...