Submission #972963

# Submission time Handle Problem Language Result Execution time Memory
972963 2024-05-01T10:59:37 Z Unforgettablepl Street Lamps (APIO19_street_lamps) C++17
20 / 100
86 ms 11196 KB
#include <bits/stdc++.h>
using namespace std;

#define int long long

bool state[300001];
int ans[300001];
int last[300001];

int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n,q;
    cin >> n >> q;
    for(int i=1;i<=n;i++){
        char a;cin>>a;
        if(a=='1')state[i]=true;
    }
    for(int i=1;i<=q;i++){
        string type;cin>>type;
        if(type=="toggle"){
            int x;cin>>x;
            if(!state[x]){
                state[x]=true;
                last[x] = i;
            } else {
                state[x]=false;
                ans[x]+=i-last[x];
            }
        } else {
            int l,r;cin>>l>>r;
            int offset = 0;
            if(state[l])offset+=i-last[l];
            cout << ans[l]+offset << '\n';
        }
    }
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 53 ms 1360 KB Output is correct
2 Correct 56 ms 4692 KB Output is correct
3 Correct 65 ms 5240 KB Output is correct
4 Correct 76 ms 11196 KB Output is correct
5 Correct 73 ms 9300 KB Output is correct
6 Correct 80 ms 10972 KB Output is correct
7 Correct 86 ms 6992 KB Output is correct
8 Correct 83 ms 8548 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2396 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -