제출 #559797

#제출 시각아이디문제언어결과실행 시간메모리
559797jeqcho가로등 (APIO19_street_lamps)C++17
20 / 100
198 ms17592 KiB
#include <bits/stdc++.h> using namespace std; typedef long double ld; typedef long long ll; typedef pair<int,int> pii; typedef vector<int> vi; typedef vector<pair<int,int>> vpi; #define FOR(i,a,b) for (int i = (a); i < (b); ++i) #define F0R(i,a) FOR(i,0,a) #define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i) #define R0F(i,a) ROF(i,0,a) #define trav(a,x) for (auto& a: x) #define pb push_back #define rsz resize #define sz(x) int(x.size()) #define all(x) begin(x), end(x) #define fi first #define se second bool valid(string s, int a, int b) { //cout<<s<<' '<<a<<' '<<b<<'\n'; FOR(i,a,b) { if(s[i]=='0')return 0; } return 1; } int const N=3e5+3; vi bad[N]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n,q; cin>>n>>q; string s; cin>>s; F0R(p,q) { string t; cin>>t; if(t=="toggle") { int i; cin>>i; --i; bad[i].pb(p); } else { int a,b; cin>>a>>b; --a;--b; bool stat=s[a]-'0'; int ans=0; int prev=0; trav(e,bad[a]) { if(stat) { ans+=e+1-prev; } stat=!stat; prev=e+1; } if(stat)ans+=p+1-prev; cout<<ans<<'\n'; } } 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...