#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll,ll> pll; typedef pair<int,int> pii; typedef vector<ll> vl; typedef vector<int> vi; typedef vector<pll> vll; typedef vector<pii> vii; typedef double db; #define pb push_back #define mp make_pair #define all(x) x.begin(),x.end() #define sz(x) (int)x.size() #define BOOST ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); #define st first #define nd second #define FOR(i,s,k) for(auto i=s; i<k; i++) #define ROF(i,s,k) for(auto i=k-1; i>=s; i--) constexpr ll inf = 1e18+1; constexpr ll MAXN = 1e6+5; constexpr ll LOGN = 18; int main() { BOOST; int n; cin>>n; int g = n/10; int cnt = 0; int ans = 0; FOR(i,0,n) { if(i%g==0) { ans += (cnt==g); cnt = 0; } char z; cin>>z; cnt += (z=='T'); } ans += (cnt==g); cnt = 0; cout<<ans; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll,ll> pll; typedef pair<int,int> pii; typedef vector<ll> vl; typedef vector<int> vi; typedef vector<pll> vll; typedef vector<pii> vii; typedef double db; #define pb push_back #define mp make_pair #define all(x) x.begin(),x.end() #define sz(x) (int)x.size() #define BOOST ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); #define st first #define nd second #define FOR(i,s,k) for(auto i=s; i<k; i++) #define ROF(i,s,k) for(auto i=k-1; i>=s; i--) constexpr ll inf = 1e18+1; constexpr ll MAXN = 1e6+5; constexpr ll LOGN = 18; int main() { BOOST; int n; cin>>n; int g = n/10; int cnt = 0; int ans = 0; FOR(i,0,n) { if(i%g==0) { ans += (cnt==g); cnt = 0; } char z; cin>>z; cnt += (z=='T'); } ans += (cnt==g); cnt = 0; cout<<ans; } |