#include <iostream> #include <vector> #include <algorithm> #include <set> #include <math.h> #include <stdio.h> #include <deque> #include <unordered_map> #include <cassert> #include <numeric> #include <queue> #include <string> #include <stack> using namespace std; int main() { std::ios_base::sync_with_stdio(false); std::cin.tie(NULL); int n; string s; cin >> n; cin >> s; int groupSize = n / 10; int res = 0; for (int g=0; g < n / groupSize; g++) { bool groupOK = true; for (int i=0; i < groupSize; i++) { if (s[g*groupSize+i] == 'N') groupOK = false; } if (groupOK) res++; } cout << res << "\n"; return 0; }
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 | #include <iostream> #include <vector> #include <algorithm> #include <set> #include <math.h> #include <stdio.h> #include <deque> #include <unordered_map> #include <cassert> #include <numeric> #include <queue> #include <string> #include <stack> using namespace std; int main() { std::ios_base::sync_with_stdio(false); std::cin.tie(NULL); int n; string s; cin >> n; cin >> s; int groupSize = n / 10; int res = 0; for (int g=0; g < n / groupSize; g++) { bool groupOK = true; for (int i=0; i < groupSize; i++) { if (s[g*groupSize+i] == 'N') groupOK = false; } if (groupOK) res++; } cout << res << "\n"; return 0; } |