#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { cin.tie(0); ios_base::sync_with_stdio(false); int n; cin >> n; string s; cin >> s; bool valid = true; int group_length = n / 10; int it = 0; int res = 0; for (int i = 0; i < s.size(); i++) { it++; if (s[i] == 'N') valid = false; if (it == group_length) { it %= group_length; if (valid) { res++; } valid = true; } } cout << res; }
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 | #include <bits/stdc++.h> using namespace std; using ll = long long; int main() { cin.tie(0); ios_base::sync_with_stdio(false); int n; cin >> n; string s; cin >> s; bool valid = true; int group_length = n / 10; int it = 0; int res = 0; for (int i = 0; i < s.size(); i++) { it++; if (s[i] == 'N') valid = false; if (it == group_length) { it %= group_length; if (valid) { res++; } valid = true; } } cout << res; } |