Submission #985224

# Submission time Handle Problem Language Result Execution time Memory
985224 2024-05-17T13:06:03 Z nnin Street Lamps (APIO19_street_lamps) C++14
20 / 100
76 ms 10724 KB
#include<bits/stdc++.h>
using namespace std;

int n, q, last[300005], ct[300005];

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin>>n>>q;
    string s;
    cin>>s;
    for(int i=0;i<n;i++) {
        if(s[i]-'0'==1) last[i] = 0;
        else last[i] = -1;
    }
    for(int i=1;i<=q;i++) {
        cin>>s;
        if(s[0]=='q') {
            int a, b;
            cin>>a>>b;
            a--; b--;
            cout<<ct[a]+(last[a]==-1 ? 0:i-last[a])<<'\n';
        } else {
            int a;
            cin>>a;
            a--;
            if(last[a]==-1) {
                last[a] = i;
            } else {
                ct[a] += (last[a]==-1 ? 0:i-last[a]);
                last[a] = -1;
            }
        }
    }
}

/*
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 1 ms 2396 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 48 ms 3308 KB Output is correct
2 Correct 55 ms 7016 KB Output is correct
3 Correct 61 ms 7448 KB Output is correct
4 Correct 69 ms 8932 KB Output is correct
5 Correct 63 ms 9188 KB Output is correct
6 Correct 63 ms 8788 KB Output is correct
7 Correct 72 ms 9580 KB Output is correct
8 Correct 76 ms 10724 KB Output is correct
# 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 1 ms 2396 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 -