Submission #233364

#TimeUsernameProblemLanguageResultExecution timeMemory
233364VimmerLjetopica (COI19_ljetopica)C++14
8 / 100
5 ms384 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...