#pragma GCC optimize("unroll-loops,Ofast,O3")
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define spc << " " <<
#define endl "\n"
#define all(x) x.begin(), x.end()
#define int long long
#define ii pair<int,int>
#define vi vector<int>
#define vii vector<ii>
#define st first
#define nd second
#define inf 1000000009
#define MOD 998244353
#define lim 200005
using namespace std;
void solve(){
int n; cin >> n;
int cnt=0;
int flag;
while(n--){
while(true){
string s; cin >> s;
flag=1;
if(s[0]-'A' >=0 && s[0]-'A'<=26){
for(int i=1; i<s.size()-1; i++){
if((s[i]-'a' <0 || s[i]-'a'>26)) flag=0;
}
if(s.size()>1 && (s[s.size()-1]!='.' && s[s.size()-1]!='?' && s[s.size()-1]!='!' && (s[s.size()-1]-'a' <0 || s[s.size()-1]-'a'>26))) flag=0;
}
else flag=0;
if(flag) cnt++;
if(s[s.size()-1]=='.' || s[s.size()-1]=='?' || s[s.size()-1]=='!'){
cout << cnt << endl;
cnt=0;
break;
}
}
}
}
signed main(){
ios_base::sync_with_stdio(false);cin.tie(0);
#ifdef Local
freopen("in","r",stdin);
freopen("out","w",stdout);
#endif
/*freopen("fcolor.in","r",stdin);
freopen("fcolor.out","w",stdout);*/
int t=1;
//cin >> t;
while(t--) solve();
}
Compilation message
imena.cpp: In function 'void solve()':
imena.cpp:31:31: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
31 | for(int i=1; i<s.size()-1; i++){
| ~^~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
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 |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
400 KB |
Output is correct |
7 |
Correct |
0 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 |