Submission #973122

# Submission time Handle Problem Language Result Execution time Memory
973122 2024-05-01T13:57:35 Z Unforgettablepl Street Lamps (APIO19_street_lamps) C++17
20 / 100
144 ms 10720 KB
#include <bits/stdc++.h>
using namespace std;

#define int long long

int tree[1048576];
int last[300001];

int get(int l,int r){
    int ans = 0;
    l+=524288;r+=524288;
    while(l<=r){
        if(l&1)ans=max(ans,tree[l++]);
        if(r%2==0)ans = max(ans,tree[r--]);
        l/=2;r/=2;
    }
    return ans;
}

void update(int k,int x){
    k+=524288;
    tree[k] = x;
    k/=2;
    while(k){
        tree[k] = max(tree[2*k],tree[2*k+1]);
        k/=2;
    }
}


int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    for(int&i:tree)i=INT32_MAX;
    int n,q;
    cin >> n >> q;
    for(int i=1;i<=n;i++){
        char a;cin>>a;
        if(a=='1')update(i,0);
    }
    for(int i=1;i<=q;i++){
        string type;cin>>type;
        if(type=="toggle"){
            int x;cin>>x;
            update(x,i);
        } else {
            int l,r;cin>>l>>r;r--;
            cout << i-min(get(l,r),i) << '\n';
        }
    }
}
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 8536 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 66 ms 9176 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 8536 KB Output is correct
2 Correct 2 ms 8540 KB Output is correct
3 Correct 2 ms 8540 KB Output is correct
4 Correct 2 ms 8540 KB Output is correct
5 Correct 78 ms 8768 KB Output is correct
6 Correct 101 ms 8904 KB Output is correct
7 Correct 112 ms 9044 KB Output is correct
8 Correct 139 ms 10580 KB Output is correct
9 Correct 62 ms 9556 KB Output is correct
10 Correct 67 ms 9552 KB Output is correct
11 Correct 72 ms 9556 KB Output is correct
12 Correct 124 ms 9312 KB Output is correct
13 Correct 144 ms 10720 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 8540 KB Output is correct
2 Incorrect 2 ms 8540 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 8536 KB Output isn't correct
2 Halted 0 ms 0 KB -