제출 #838249

#제출 시각아이디문제언어결과실행 시간메모리
838249manizare가로등 (APIO19_street_lamps)C++14
20 / 100
420 ms9904 KiB
#include <bits/stdc++.h> #define pb push_back #define F first #define S second #define all(a) a.begin(),a.end() #define pii pair<int,int> using namespace std ; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); const int maxn = 1000 + 10 , inf = 1e9+10 ; int pre[maxn][maxn] ; signed main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n , q; cin >>n >> q; string s; cin >> s; s= "0" + s; for(int j = 1; j <= n ; j++){ pre[0][j] = pre[0][j-1] + (s[j] == '0'); } for(int i = 1; i <= q ; i++){ string a ; cin >> a; if(a[0] == 't'){ int x; cin >> x; if(s[x] == '0')s[x] = '1' ; else s[x] = '0' ; } for(int j = 1; j <= n; j++){ pre[i][j] = pre[i][j-1] + (s[j] == '0') ; } if(a[0] == 'q'){ int r , l; cin >> l >> r ; r--; int ans = 0 ; for(int j = 0; j < i ;j++){ if(pre[j][r] == pre[j][l-1]){ ans ++ ; } } cout <<ans << "\n"; } } } /* 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 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...