#include <bits/stdc++.h> using namespace std; const int D = 10; int solve(int n, string s) { int score = 0; int m = s.size() / D; bool allPassed = true; for (int i = 0; i < n; i++) { if (s[i] == 'N') { allPassed = false; } if ((i + 1) % m == 0) { if (allPassed) { score++; } allPassed = true; } } return score; } int main() { ios_base::sync_with_stdio(false); int n; cin >> n; string s; cin >> s; cout << solve(n, s) << endl; }
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 | #include <bits/stdc++.h> using namespace std; const int D = 10; int solve(int n, string s) { int score = 0; int m = s.size() / D; bool allPassed = true; for (int i = 0; i < n; i++) { if (s[i] == 'N') { allPassed = false; } if ((i + 1) % m == 0) { if (allPassed) { score++; } allPassed = true; } } return score; } int main() { ios_base::sync_with_stdio(false); int n; cin >> n; string s; cin >> s; cout << solve(n, s) << endl; } |