알고리즘/백준
백준 4775 Spelling Be
등반
2021. 12. 27. 00:20
https://www.acmicpc.net/problem/4775
4775번: Spelling Be
The input consists of two sections, the dictionary and the emails. The first line of input specifies the number of words in the dictionary, followed by that many lines, with one word per line. There is no whitespace before, after, or in any words, although
www.acmicpc.net
입력
정수 N
N개의 단어(사전에 등재할 단어)
정수 M
M개의 email (마지막 한 줄은 '-1'로 끝난다)
문제 해설
email에 있는 단어 중 사전에 등재되지 않는 단어가 있는지 구분하고, 있다면 모두 출력하는 문제다.
#include <iostream>
#define fio cin.tie(0)->sync_with_stdio(0)
using namespace std;
#include <set>
#include <vector>
int main(){
fio;
int N; cin >> N;
set<string> dict;
for(int i=0; i< N; i++){
string S; cin >> S;
dict.insert(S);
}
int num_of_email; cin >> num_of_email;
for(int i=1; i <= num_of_email; i++){
vector<string> not_exist;
bool good = true;
string S;
while(1){
cin >> S;
if(S == "-1") break;
if(dict.find(S) != dict.end()){
//
}else{
good = false;
not_exist.push_back(S);
}
}
if(good){
cout << "Email " << i <<" is spelled correctly.\n";
}else{
cout << "Email " << i <<" is not spelled correctly.\n";
}
for(auto a : not_exist){
cout << a <<'\n';
}
//
}
cout << "End of Output\n";
return 0;
}