#include<bits/stdc++.h>
using namespace std;
void solve(){
int n,i;
char c;
cin >> n >> c;
string s;
cin >> s;
int mx = 0, last = 0;
for(int i = 2 * n; i >= 1 ; i -- ) {
if(s[i] == 'g') last = i;
if(s[i] == 'c') mx = max(mx, last - i);
}
cout << mx << endl;
}
int main(){
ios::sync_with_stdio(false),cin.tie(),cout.tie();
int y;
cin>>y;
for(int b=1;b<=y;++b) solve();
return 0;
}
话说为啥错?
cf 1744 c