Submission #558350

# Submission time Handle Problem Language Result Execution time Memory
558350 2022-05-07T06:56:05 Z Yazan_Alattar Izlet (COI19_izlet) C++14
0 / 100
1 ms 340 KB
#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, mn, mx;

ll solve(ll i, ll rem, ll cost, bool flip){
    if(rem < 0) return 0;
    if(i == n - 1){
        if(rem || cost < mn || cost > mx) return 0ll;
        return cost;
    }

    ll ret = 0;
    if(flip){
        if(s[i] == 'L') ret = (solve(i + 1, rem - 1, cost * 2 + 1, flip ^ 1) + solve(i + 1, rem, cost * 2 + 1, flip)) % mod;
        else  ret = (solve(i + 1, rem - 1, cost * 2, flip ^ 1) + solve(i + 1, rem, cost * 2, flip)) % mod;
    }
    else{
        if(s[i] == 'R') ret = (solve(i + 1, rem - 1, cost * 2 + 1, flip ^ 1) + solve(i + 1, rem, cost * 2 + 1, flip)) % mod;
        else  ret = (solve(i + 1, rem - 1, cost * 2, flip ^ 1) + solve(i + 1, rem, cost * 2, flip)) % mod;
    }

    return ret;
}

int main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n >> k >> s >> a >> b;

    for(int i = 0; i < n; ++i){
        mn = mn * 2 + a[i] - '0';
        mx = mx * 2 + b[i] - '0';
    }

    cout << (solve(0, k, 1, 1) + solve(0, k, 1, 0)) % mod << endl;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Integer 0 violates the range [1, 30]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB Integer 0 violates the range [1, 3000]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Integer 0 violates the range [1, 30]
2 Halted 0 ms 0 KB -