2023 rcpc

This commit is contained in:
2024-04-22 16:45:09 +03:00
parent a0ddb657b7
commit 156202ada0
61 changed files with 4462 additions and 0 deletions

View File

@@ -0,0 +1,38 @@
/// Gheorghies Alexandru - greedy solution
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pld;
const ll LGMAX=20,NMAX=3e5+5;
void tc(){
ll n,ans=0,len=0;
string s;
cin>>n>>s;
for(ll i=0;i<n;i++){
if(i && s[i]!=s[i-1]) len++;
else{
ans+=(len+1)/3;
len=0;
}
}
ans+=(len+1)/3;
cout<<ans<<'\n';
}
int main()
{
#ifndef ONLINE_JUDGE
freopen("in.txt","r",stdin);
freopen("out.txt","w",stdout);
#endif // ONLINE_JUDGE
ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
ll t; cin>>t; while(t--)
tc();
return 0;
}