Submission #864339

# Submission time Handle Problem Language Result Execution time Memory
864339 2023-10-22T14:30:04 Z gutzzy Imena (COCI16_imena) C++14
50 / 50
1 ms 608 KB
#include <bits/stdc++.h>
using namespace std;

bool name(string s){
    bool first = true;
    for(char c:s){
        if(isdigit(c)) return false;

        if(first){
            if(c != toupper(c)) return false;
        }
        else{
            if(c != tolower(c)) return false;
        }
        first = false;
    }
    return true;
}

int main(){
    int n;
    cin >> n;
    
    //cout << toupper('c') << toupper('C') << tolower('C') << endl;
    //cout << name("Hola")<<endl;
    //<< " " << name("a4") << " " << name("4a") << " " << name("ajs") << endl;
    
    for(int xx=0;xx<n;xx++){
        string s;
        vector<string> sentence;
        cin >> s;
        while(s[s.size()-1]!='.' and s[s.size()-1]!='?' and s[s.size()-1]!='!'){
            sentence.push_back(s);
            cin >> s;
        }
        sentence.push_back(s.substr(0,s.size()-1));
        
        int c=0;
        
        for(string word:sentence){
            if(name(word)) c++;
        }
        
        cout << c << endl;
    }

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 608 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct