제출 #559800

#제출 시각아이디문제언어결과실행 시간메모리
559800jeqcho가로등 (APIO19_street_lamps)C++17
20 / 100
5067 ms10268 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 main() { ios_base::sync_with_stdio(0); cin.tie(0); int n,q; cin>>n>>q; string s; cin>>s; vpi qs; F0R(p,q) { string t; cin>>t; if(t=="toggle") { int i; cin>>i; qs.pb({i-1,-1}); } else { int a,b; cin>>a>>b; --a;--b; qs.pb({a,b}); } } F0R(i,q) { if(qs[i].se==-1)continue; int a=qs[i].fi; int b=qs[i].se; int ans=0; string road=s; F0R(j,i+1) { if(valid(road,a,b))++ans; if(qs[j].se==-1)road[qs[j].fi]=(!(road[qs[j].fi]-'0'))+'0'; } 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...