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>
using namespace std;
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n, q;
cin>>n;
string a;
cin>>a>>q;
while(q--)
{
int l, r, c=0, p=0, rez=0;
cin>>l>>r;
l--, r--;
for(int i=l; i<=r; i++)
{
if(a[i]=='C')
c++;
else if(a[i]=='T')
p++;
if(p>c)
{
a[i]='#';
p--;
rez++;
}
}
c=0, p=0;
for(int i=r; i>=l; i--)
{
if(a[i]=='C')
c++;
else if(a[i]=='T')
p++;
if(p>c)
{
p--;
rez++;
}
if(a[i]=='#')
a[i]='T';
}
cout<<rez<<"\n";
}
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... |