# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
144218 | emilem | Ljetopica (COI19_ljetopica) | C++14 | 4 ms | 380 KiB |
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 <algorithm>
#include <iostream>
#include <vector>
#include <string>
using namespace std;
const long long mod = 1000000007;
long long ans = 0;
int n, k;
string path, a, b;
vector<int> pow2(2000);
void Solve1(string path)
{
string res = "1";
for (int i = 0; i < path.length(); ++i)
{
res.push_back('0');
if (path[i] == 'R')
res.back() = '1';
}
if (res.length() < a.length() || res.length() > b.length())
return;
if (res < a || res > b)
return;
reverse(res.begin(), res.end());
for (int i = 0; i < res.length(); ++i)
if (res[i] == '1')
{
ans += pow2[i];
ans %= mod;
}
}
int main()
{
pow2[0] = 1;
for (int i = 1; i < pow2.size(); ++i)
pow2[i] = (pow2[i - 1] + pow2[i - 1]) % mod;
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
cin >> n >> k;
cin >> path;
cin >> a >> b;
if (!k)
{
Solve1(path);
for (int i = 0; i < path.length(); ++i)
path[i] = (path[i] == 'L' ? 'R' : 'L');
Solve1(path);
cout << ans << endl;
}
else
{
}
char I;
cin >> I;
}
Compilation message (stderr)
# | 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... |