Submission #145511

# Submission time Handle Problem Language Result Execution time Memory
145511 2019-08-20T10:07:56 Z saken03 Ljetopica (COI19_ljetopica) C++14
0 / 100
2 ms 376 KB
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

#define pb push_back
#define mp make_pair

#define all(x) (x).begin(), (x).end()

#define fi first
#define se second

using namespace std;

//template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

using namespace __gnu_pbds;
const int MOD = (int)1e9 + 7;

int n, k;

string s;

void solve() {
    cin >> n >> k;

    cin >> s;

    string a1, b1;
    cin >> a1 >> b1;

    int a = 0, b = 0;

    reverse(all(a1));
    reverse(all(b1));

    for (int i = 0; i < a1.size(); i++) {
        if (a1[i] == '1') a += (1 << i);
        a %= MOD;
    }

    for (int i = 0; i < b1.size(); i++) {
        if (b1[i] == '1') b += (1 << i);
        b %= MOD;
    }


    int sum = 0, pt = 1;

    for (int i = 0; i < s.size(); i++) {
        if (s[i] == 'L') {
            pt *= 2;
        }
        if (s[i] == 'R') {
            pt = pt * 2 + 1;
        }

        if (pt >= a && pt <= b) {
            sum = (sum + pt) % MOD;
        }
    }
    pt = 1;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == 'L') {
            pt = pt * 2 + 1;
        }
        else {
            pt = pt * 2;
        }
        if (pt >= a && pt <= b) {
            sum = (sum + pt) % MOD;
        }
    }

    cout << sum << '\n';

}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    int tt = 1;

    while (tt--) {
        solve();
    }

    return 0;
}

Compilation message

ljetopica.cpp: In function 'void solve()':
ljetopica.cpp:37:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = 0; i < a1.size(); i++) {
                     ~~^~~~~~~~~~~
ljetopica.cpp:42:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = 0; i < b1.size(); i++) {
                     ~~^~~~~~~~~~~
ljetopica.cpp:50:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = 0; i < s.size(); i++) {
                     ~~^~~~~~~~~~
ljetopica.cpp:63:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = 0; i < s.size(); i++) {
                     ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -