This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
//Sani buyuk Osman Pasa Plevneden cikmam diyor.
//FatihSultanMehmedHan
//Abdulhamid Han
//Bismillahirrahmanirrahim
//█▀█─█──█──█▀█─█─█
//█▄█─█──█──█▄█─█▄█
//█─█─█▄─█▄─█─█─█─█
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long lo;
typedef pair< lo,lo > PII;
#define fi first
#define se second
#define int long long
#define mp make_pair
#define pb push_back
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(int i=1;i<=n;i++)
#define mid ((start+end)/2)
#define ort ((bas+son)/2)
const lo MAX = -1000000000000000000;
const lo MIN = 1000000000000000000;
const lo inf = 1000000000;
const lo KOK = 100000;
const lo LOG = 30;
const lo li = 500005;
const lo mod = 1000000007;
int n,m,b[li],a[li],k,flag,t;
int cev;
string s,s1,s2;
vector<int> v;
inline int add(int x,int y){
if(x+y>=mod)return x+y-mod;
return x+y;
}
inline int mul(int x,int y){
return (x%mod)*(y%mod)%mod;
}
inline void dfs(int sira,int der,string ss){
if(der==n){
//~ cout<<ss<<endl;
if(ss>=s1 && ss<=s2){
int carp=1;
for(int i=(int)ss.size()-1;i>=0;i--){
cev=add(cev,mul(carp,(ss[i]-'0')));
carp=mul(carp,2);
}
}
return ;
}
if(s[sira]=='L')dfs(sira+1,der+1,ss+'0');
else dfs(sira+1,der+1,ss+'1');
}
main(void){
fio();
cin>>n>>k;
cin>>s;
cin>>s1>>s2;
string st{};
st+='1';
dfs(0,1,st);
for(int i=0;i<(int)s.size();i++){
if(s[i]=='L')s[i]='R';
else s[i]='L';
}
dfs(0,1,st);
cout<<cev<<endl;
return 0;
}
Compilation message (stderr)
ljetopica.cpp:67:10: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
main(void){
^
# | 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... |