이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
/*
#pragma GCC optimize("-Ofast")
//#pragma GCC optimize("trapv")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.2,popcnt,abm,mmx,avx2,tune=native")
#pragma GCC optimize("-ffast-math")
#pragma GCC optimize("-funroll-loops")*/
#define I inline void
#define S struct
#define vi vector<int>
#define vii vector<pair<int,int>>
#define pii pair<int,int>
#define pll pair<ll,ll>
using namespace std ;
using ll = long long ;
using ld = long double ;
const int N = 1e5 + 7 , mod = 1e9 + 7 ;
const int inf = N ;
// How interesting!
int n , k ;
string s;
int a[N] ;
string tmp[N] ;
int ts ;
int solve(int l , int r){
int ret = 0 ;
int x = r - l + 1;
for(int i = 0 ;i <= ts ; i ++){
// cout<< tmp[i] <<" " ;
ret+= (tmp[i].substr(l , x) == string(x , '1') ) ;
}
// cout<<"-----\n" ;
//if(ts)
// exit(0) ;
return ret ;
}
int main(){
ios_base::sync_with_stdio(0) ;
cin.tie(0) ;
//freopen("in.in" , "r" , stdin) ;
cin >> n >> k ;
cin >> s ;
tmp[0] = s;
for(int i = 0 ;i < n;i ++)
a[i] = s[i] - '0' ;
for(int i = 0 ;i < k ;i ++){
string t ;
int l , r;
cin >> t ;
if(t == "toggle"){
cin >> l ;
tmp[ts+1] = tmp[ts] ;ts++;
tmp[ts][l-1] = '1' - tmp[ts][l-1] + '0';
a[l] ^=1 ;
} else{
cin >> l >> r;
l-- ; r-=2;
cout<< solve(l , r) <<"\n";
tmp[ts + 1] = tmp[ts] ; ts ++ ;
}
}
return 0 ;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |