답안 #630648

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
630648 2022-08-16T19:45:31 Z inksamurai Imena (COCI16_imena) C++17
50 / 50
1 ms 324 KB
#include <bits/stdc++.h>
using namespace std;
#define sz(a) (int)a.size()
#define _3phCa4T ios::sync_with_stdio(0),cin.tie(0)
void print(){cout<<'\n';}
template<class h,class...t>
void print(const h&v,const t&...u){cout<<v<<' ',print(u...);}
// e

signed main(){
_3phCa4T;
	int n;
	cin>>n;
	string s;
	getline(cin,s);
	getline(cin,s);
	string word="";
	int now=0;
	auto af=[&](string word)->bool{
		if(sz(word)){
			bool h=0;
			if('A'<=word[0] and word[0]<='Z'){
				h=1;
			}
			bool t=1;
			for(int j=1;j<sz(word);j++){
				if(!('a'<=word[j] and word[j]<='z')){
					t=0;
				}
			}
			return h*t;
		}
		return 0;
	};
	for(int i=0;i<sz(s);i++){
		if(s[i]==' '){
			now+=af(word);
			word="";
		}else if(s[i]=='.' or s[i]==',' or s[i]=='?' or s[i]=='!'){
			now+=af(word);
			word="";
			print(now);
			now=0;
		}else{
			word+=s[i];
		}
	}
}

Compilation message

imena.cpp: In lambda function:
imena.cpp:31:12: warning: '*' in boolean context, suggest '&&' instead [-Wint-in-bool-context]
   31 |    return h*t;
      |           ~^~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 324 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 320 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 316 KB Output is correct