Submission #242463

#TimeUsernameProblemLanguageResultExecution timeMemory
242463MatesV13Ljetopica (COI19_ljetopica)C++11
8 / 100
5 ms384 KiB
#include <bits/stdc++.h> using namespace std; long long n, k, ans, mod=1000000007; string upute, l, r, rj1, rj2; bool comp (string manji, string veci){ if (manji.size()!=veci.size()) return manji.size() < veci.size(); return manji <= veci; } int main (){ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> k; cin >> upute; cin >> l; cin >> r; rj1="1", rj2="1"; for (int i=0; i<n-1; i++){ if (upute[i]=='L') {rj1+='0'; rj2+='1';} else {rj1+='1'; rj2+='0';} } if (comp(l, rj1) and comp(rj1, r)){ long long sol=0; for (int i=0; i<n; i++){ sol*=2; sol+=rj1[i]-'0'; sol%=mod; } ans+=sol; } if (comp(l, rj2) and comp(rj2, r)){ long long sol=0; for (int i=0; i<n; i++){ sol*=2; sol+=rj2[i]-'0'; sol%=mod; } ans+=sol; } ans%=mod; cout << ans; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...