This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
int main()
{
std::ios::sync_with_stdio(false);
std::cin.tie(0);
std::cout.tie(0);
int N;
std::cin>>N;
std::string s;
std::cin >> s;
int Q;
std::cin>>Q;
for(int i=0;i!=Q;++i){
int l,r;
std::cin>>l>>r;--l;--r;
std::string nov = s;
int s=0;
int ans=0;
for(int j=l;j!=r+1;++j){
if(nov[j]=='C')++s;else if(nov[j]=='T'){
--s;
if(s<0){
++s;
++ans;
nov[j]='N';
}
}
}
s=0;
for(int j=r;j!=l-1;--j){
if(nov[j]=='C')++s;else if(nov[j]=='T'){
--s;
if(s<0){
++s;
++ans;
nov[j]='N';
}
}
}
std::cout<<ans<<"\n";
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |