Submission #397510

# Submission time Handle Problem Language Result Execution time Memory
397510 2021-05-02T10:14:58 Z Alma Imena (COCI16_imena) C++17
50 / 50
1 ms 332 KB
#include <bits/stdc++.h>
using namespace std;

bool name (string & s, int m) {
    if ('A' <= s[0] && s[0] <= 'Z') {} else return false;
    for (int i = 1; i < m; i++) {
        if ('a' <= s[i] && s[i] <= 'z') continue;
        else if ((s[i] == '.' || s[i] == '?') || s[i] == '!') continue;
        else return false;
    }
    return true;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int n, m, sentence = 1, names = 0;
    cin >> n;
    string s;
    while (cin >> s) {
        if (sentence > n) break;
        int m = (int)s.size();
        if (name(s, m)) names++;
        if ((s[m-1] == '.' || s[m-1] == '?') || s[m-1] == '!') {
            cout << names << '\n';
            names = 0; sentence++;
        }
    }
    return 0;
}

Compilation message

imena.cpp: In function 'int main()':
imena.cpp:17:12: warning: unused variable 'm' [-Wunused-variable]
   17 |     int n, m, sentence = 1, names = 0;
      |            ^
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 312 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct