Submission #716546

# Submission time Handle Problem Language Result Execution time Memory
716546 2023-03-30T09:35:54 Z 1zaid1 Street Lamps (APIO19_street_lamps) C++17
0 / 100
12 ms 23788 KB
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define endl '\n'

const signed M = 3e6, MOD = 998244353;

int N = 1 << 20;
int seg[M];

void update(int ind) {
    while (ind /= 2) seg[ind] = max(seg[ind*2], seg[ind*2+1]);
}
 
int query(int L, int R, int l = 1, int r = N, int ind = 1) {
    if (r < L || l > R) return INT_MAX;
    if (L <= l && r <= R) return seg[ind];
    return max(query(L, R, l, (l+r)/2, ind*2), query(L, R, (l+r)/2+1, r, ind*2+1));
}

signed main() {
    cin.tie(0)->sync_with_stdio(0);
    for (int &i:seg) i = INT_MAX;

    int n, q;
    cin >> n >> q;

    string s;
    cin >> s;
    for (int i = 0; i < n; i++) {
        if (s[i] == '1') seg[N+i-1] = 0, update(N+i-1);
    }

    for (int i = 1; i <= n; i++) {
        string s;
        cin >> s;

        if (s == "query") {
            int l, r;
            cin >> l >> r;
            cout << max(0ll, i-query(l, r)) << endl;
        } else {
            int x;
            cin >> x;
            seg[N+x-1] = i;
            update(N+x-1);
        }
    }

    return 0;
}
/*
5 7
11011
query 1 2
query 1 2
query 1 6
query 3 4
toggle 3
query 3 4
query 1 6
*/
# Verdict Execution time Memory Grader output
1 Incorrect 10 ms 23764 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 10 ms 23788 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 12 ms 23764 KB Output is correct
2 Incorrect 11 ms 23764 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 11 ms 23764 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 10 ms 23764 KB Output isn't correct
2 Halted 0 ms 0 KB -