# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
145542 | Ok_google | Ljetopica (COI19_ljetopica) | C++17 | 3 ms | 376 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<bits/stdc++.h>
#define pb push_back
#define fr first
#define sc second
#define ll long long
using namespace std;
const int mnx = 1e6 + 5;
const int mod = 1e9 + 7;
ll n, k;
string s;
string a, b;
bool gon(string a, string b){
if(a.size() > b.size()) return 1;
if(a.size() < b.size()) return 0;
for(int i = 1; i <= a.size(); i++){
if(a[i] > b[i]) return 1;
if(a[i] < b[i]) return 0;
}
return 1;
}
string x, y;
string mkd(string a, string b){
string c;
for(int i = 0; i <= a.size(); i++){
c += '0';
}
for(int i = a.size() - 1; i >= 0; i--){
c[i + 1] = c[i + 1] + a[i] + b[i] - '0' - '0';
if(c[i + 1] >= '2'){
c[i + 1] -= 2;
c[i] += 1;
}
}
return c;
}
ll asd(string s){
ll k = 1;
ll sum = 0;
for(int i = s.size() - 1; i >= 0; i--){
if(s[i] == '1'){
sum += k;
sum %= mod;
}
k *= 2;
k %= mod;
}
return sum;
}
int main(){
cin >> n >> k;
cin >> s;
cin >> a >> b;
if(k != 0){
cout << 0 << '\n';
return 0;
}
x = "1";
y = "1";
for(int i = 0; i < s.size(); i++){
x += (s[i] == 'R') + '0';
y += (s[i] == 'L') + '0';
}
bool ok = 0;
bool ko = 0;
if(gon(b, x) && gon(x, a)){
ok = 1;
}
if(gon(b, y) && gon(y, a)){
ko = 1;
}
string f, z;
if(ok && ko){
z = mkd(x, y);
}
if(ok && !ko){
z = x;
}
if(!ok && ko){
z = y;
}
cout << asd(z) << '\n';
return 0;
}
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... |