This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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);
int n, k;
cin >> n >> k;
int a = 0, b = 0;
string s;
cin >> s;
string t;
cin >> t;
for (int i = 0; i < sz(t); i++)
{
if (t[i] == '1') {a *= 2; a++;}
else a *= 2;
}
cin >> t;
for (int i = 0; i < sz(t); i++)
{
if (t[i] == '1') {b *= 2; b++;}
else b *= 2;
}
int pos1 = 1, pos2 = 1;
for (int i = 0; i < sz(s); i++)
{
if (s[i] == 'L')
{
pos1 *= 2;
pos2 *= 2;
pos2++;
}
else
{
pos1 *= 2;
pos1++;
pos2 *= 2;
}
}
int ans = 0;
if (a <= pos1 && pos1 <= b) ans += pos1;
if (a <= pos2 && pos2 <= b) ans += pos2;
cout << ans << endl;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |