#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 more(string s, string t)
{
if (sz(s) > sz(t)) return 1;
if (sz(s) < sz(t)) return 0;
for (int i = 0; i < sz(s); i++)
{
if (s[i] == t[i]) continue;
if (s[i] == '1') return 1;
return 0;
}
return 2;
}
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 = 1, b = 1;
string s, t1 = "1", t2 = "1";
cin >> s;
for (int i = 0; i < sz(s); i++)
{
if (s[i] == 'L')
{
a *= 2;
b *= 2;
b %= M;
b++;
a %= M;
b %= M;
t1 += '0';
t2 += '1';
}
else
{
a *= 2;
b *= 2;
a %= M;
a++;
a %= M;
b %= M;
t1 += '1';
t2 += '0';
}
}
string s1, s2;
cin >> s1;
cin >> s2;
ll ans = 0;
if (more(t1, s1) != 0 && more(s2, t1) != 0) ans = a;
if (more(t2, s1) != 0 && more(s2, t2) != 0) ans = (ans + b) % M;
cout << ans << endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
4 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
5 ms |
384 KB |
Output is correct |
6 |
Correct |
5 ms |
384 KB |
Output is correct |
7 |
Correct |
4 ms |
384 KB |
Output is correct |
8 |
Correct |
5 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
4 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
5 ms |
384 KB |
Output is correct |
6 |
Correct |
5 ms |
384 KB |
Output is correct |
7 |
Correct |
4 ms |
384 KB |
Output is correct |
8 |
Correct |
5 ms |
384 KB |
Output is correct |
9 |
Incorrect |
5 ms |
384 KB |
Output isn't correct |
10 |
Halted |
0 ms |
0 KB |
- |