Submission #558347

#TimeUsernameProblemLanguageResultExecution timeMemory
558347Yazan_AlattarLjetopica (COI19_ljetopica)C++14
8 / 100
1 ms324 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; #define F first #define S second #define pb push_back #define endl "\n" #define aint(x) x.begin(), x.end() const int M = 3007; const ll inf = 2e9; const ll mod = 1e9 + 7; const double pi = acos(-1); const double eps = 1e-6; const int dx[] = {0, -1, 0, 1}, dy[] = {1, 0, -1, 0}; const int block = 320; string s, a, b; ll n, k; ll check(string s){ ll res = 1; int mn = 1, mx = 1; for(int i = 0; i < n - 1; ++i){ if(s[i] == 'L'){ // bit = 0 res = (res * 2) % mod; if(mx == 1 && a[i + 1] == '1') mx = 0; if(mn == 1 && b[i + 1] == '1') mn = 2; } else{ // bit = 1 res = (res * 2 + 1) % mod; if(mx == 1 && a[i + 1] == '0') mx = 2; if(mn == 1 && b[i + 1] == '0') mn = 0; } } if(mn && mx) return res; return 0ll; } int main(){ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); string S; cin >> n >> k >> S >> a >> b; ll ans = check(S); for(int i = 0; i < n - 1; ++i){ if(S[i] == 'L') S[i] = 'R'; else S[i] = 'L'; } ans += check(S); cout << ans % mod << endl; 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...