Submission #1044876

# Submission time Handle Problem Language Result Execution time Memory
1044876 2024-08-05T14:15:52 Z vjudge1 Street Lamps (APIO19_street_lamps) C++17
20 / 100
91 ms 15332 KB
#pragma GCC optimize("unroll-loops,Ofast,O3")
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define spc << " " <<
#define endl "\n"
#define all(x) x.begin(), x.end()
#define int long long
#define ii pair<long long,int>
#define vi vector<int>
#define vii vector<ii>
#define st first
#define nd second
#define inf 1e15
#define MOD 1000000007
#define MX 200005
using namespace std;



void solve(){
    int n,q; cin >> n >> q;
    string s; cin >> s;
    int tot[n+1], last[n+1], cur[n+1];
    for(int i=1; i<=n; i++){
        tot[i]=0;
        last[i]=0;
        cur[i]=s[i-1]-'0';
    }
    for(int i=1; i<=q; i++){
        cin >> s;
        if(s[0]=='t'){
            int a; cin >> a;
            if(cur[a]==0){
                last[a]=i;
            }
            else{
                tot[a]+=i-last[a];
            }
            cur[a]=1-cur[a];
        }
        else{
            int l,r; cin >> l >> r;
            int ans=tot[l];
            if(cur[l]) ans+=i-last[l];
            cout << ans << endl;
        }
    }
}
 
 
signed main(){
    ios_base::sync_with_stdio(false);cin.tie(0);
    #ifdef Local
    freopen("in","r",stdin);
    freopen("out","w",stdout);
    #endif
 
    /*freopen("nondec.in","r",stdin);
    freopen("nondec.out","w",stdout);*/
 
    int t=1;
    //cin >> t;
    while(t--) solve();
}
# 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 38 ms 2632 KB Output is correct
2 Correct 37 ms 4436 KB Output is correct
3 Correct 59 ms 5204 KB Output is correct
4 Correct 51 ms 13028 KB Output is correct
5 Correct 53 ms 13540 KB Output is correct
6 Correct 48 ms 12748 KB Output is correct
7 Correct 64 ms 13800 KB Output is correct
8 Correct 91 ms 15332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 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 -