Submission #88452

# Submission time Handle Problem Language Result Execution time Memory
88452 2018-12-06T01:30:31 Z xiaowuc1 Imena (COCI16_imena) C++14
50 / 50
2 ms 636 KB
#include <bits/stdc++.h>

using namespace std;

void solve() {
  string s;
  int ret = 0;
  while(true) {
    s = "";
    cin >> s;
    if(s.size() == 0) break;
    bool bad = false;
    if(s[0] < 'A' || s[0] > 'Z') bad = true;
    for(int i = 1; i < s.size()-1; i++) {
      bool letter = s[i] >= 'A' && s[i] <= 'Z';
      letter |= s[i] >= 'a' && s[i] <= 'z';
      bad |= !letter;
    }
    {
      bool perm = false;
      perm |= s[s.size()-1] >= 'A' && s[s.size()-1] <= 'Z';
      perm |= s[s.size()-1] >= 'a' && s[s.size()-1] <= 'z';
      perm |= s[s.size()-1] == '!';
      perm |= s[s.size()-1] == '?';
      perm |= s[s.size()-1] == '.';
      bad |= !perm;
    }
    if(!bad) ret++;
    if(s[s.size()-1] == '.' || s[s.size()-1] == '!' || s[s.size()-1] == '?') {
      cout << ret << endl;
      ret = 0;
    }
  }
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  solve();
}

Compilation message

imena.cpp: In function 'void solve()':
imena.cpp:14:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 1; i < s.size()-1; i++) {
                    ~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 1 ms 508 KB Output is correct
3 Correct 2 ms 508 KB Output is correct
4 Correct 2 ms 508 KB Output is correct
5 Correct 2 ms 508 KB Output is correct
6 Correct 2 ms 596 KB Output is correct
7 Correct 1 ms 596 KB Output is correct
8 Correct 2 ms 636 KB Output is correct
9 Correct 2 ms 636 KB Output is correct
10 Correct 2 ms 636 KB Output is correct