Submission #425121

#TimeUsernameProblemLanguageResultExecution timeMemory
425121SAADStreet Lamps (APIO19_street_lamps)C++17
0 / 100
5031 ms3196 KiB
#define F first
#define S second
#define rep(i,a,b) for(int i=a;!(a==b&&i!=b)&&((i<=b&&b>=a)||(i>=b&&a>=b));i+=(a<=b?1:-1))
#define pb push_back
#define Fbitl __builtin_ffs
#define bit1 __builtin_popcount
#define pi acos(-1)
//#include <bits/stdc++.h>
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string.h>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<string, string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vii;
typedef vector<ll> vl;
typedef vector<vl> vvl;
int num[300002] ;
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n , q,p,b;
    cin >> n >> q;
    string s,a,g=" ";
    cin >> s;
    g += s ;
    s = g ;
    vector <string> qe ;
    while ( q-- ) {
        cin >> a;
        if (a == "toggle") {
            cin >> p;
            s[p] = (s[p]-48?'0':'1');
        }
        else {
            qe.pb(s);
            cin >> p >> b ;
            int res = 0 ;
            for (auto i:qe) {
                bool th = true; 
                for (int j=p;j<b;j++) {
                    if(th&&i[j]=='0')th=false;
                }
                if(th)res++;
            }
            cout << res << endl ;
        }
    }
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...