답안 #88451

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
88451 2018-12-06T01:30:01 Z xiaowuc1 Imena (COCI16_imena) C++14
35 / 50
3 ms 692 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(); 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(); i++) {
                    ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 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 3 ms 648 KB Output is correct
6 Correct 2 ms 648 KB Output is correct
7 Incorrect 2 ms 692 KB Output isn't correct
8 Incorrect 2 ms 692 KB Output isn't correct
9 Correct 2 ms 692 KB Output is correct
10 Incorrect 2 ms 692 KB Output isn't correct