#include <iostream> #include <algorithm> #include <vector> #include <map> #define push push_back #define ll long long using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n; cin >> n; vector<bool> T(n); for(int i = 0; i < n; i++) { char temp; cin >> temp; if(temp == 'T') { T[i] = 1; }else { T[i] = 0; } } int gR = (n/10); int gmR = (n/gR); vector<int> cR(gmR); for(int i = 0; i < n; i++) { int gcR = ((i)/(gR)); if(T[i] == 1){ // cout << i << " | " << T[i] << " " << gcR << "\n"; cR[gcR]++; } } int result = 0; for(int i = 0; i < gmR; i++) { // cout << cR[i] << "\n"; if(cR[i] == gR) { result++; } } cout << result << "\n"; }
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 47 48 49 50 51 52 | #include <iostream> #include <algorithm> #include <vector> #include <map> #define push push_back #define ll long long using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n; cin >> n; vector<bool> T(n); for(int i = 0; i < n; i++) { char temp; cin >> temp; if(temp == 'T') { T[i] = 1; }else { T[i] = 0; } } int gR = (n/10); int gmR = (n/gR); vector<int> cR(gmR); for(int i = 0; i < n; i++) { int gcR = ((i)/(gR)); if(T[i] == 1){ // cout << i << " | " << T[i] << " " << gcR << "\n"; cR[gcR]++; } } int result = 0; for(int i = 0; i < gmR; i++) { // cout << cR[i] << "\n"; if(cR[i] == gR) { result++; } } cout << result << "\n"; } |