Sicily 1194. Message Flood
2015-05-23 17:12
253 查看
注意: 不区分大小写, 所以需要转换成统一小写, 方便比较
另A为联系人集合, B为发送人集合
题意就是求: A - B
// Problem#: 1194
// Author#: Reid Chan
#include <iostream>
#include <cctype>
#include <set>
using namespace std;
void to_low(string &a, string b, int l) {
for (int i = 0; i < l; i++) {
a += tolower(b[i]);
}
}
int main() {
int n, m;
while (cin >> n >> m && n != 0) {
set<string> contacts, senders;
string name;
string ins;
int len;
for (int i = 0; i < n; ++i) {
cin >> name;
ins = "";
len = name.length();
to_low(ins, name, len);
contacts.insert(ins);
}
for (int i = 0; i < m; ++i) {
cin >> name;
ins = "";
len = name.length();
to_low(ins, name, len);
senders.insert(ins);
}
int num = contacts.size();
set<string>::iterator it;
for (it = senders.begin(); it != senders.end(); ++it) {
if (contacts.find(*it) != contacts.end()) {
contacts.erase((*it));
}
}
cout << contacts.size() << endl;
}
return 0;
}
另A为联系人集合, B为发送人集合
题意就是求: A - B
// Problem#: 1194
// Author#: Reid Chan
#include <iostream>
#include <cctype>
#include <set>
using namespace std;
void to_low(string &a, string b, int l) {
for (int i = 0; i < l; i++) {
a += tolower(b[i]);
}
}
int main() {
int n, m;
while (cin >> n >> m && n != 0) {
set<string> contacts, senders;
string name;
string ins;
int len;
for (int i = 0; i < n; ++i) {
cin >> name;
ins = "";
len = name.length();
to_low(ins, name, len);
contacts.insert(ins);
}
for (int i = 0; i < m; ++i) {
cin >> name;
ins = "";
len = name.length();
to_low(ins, name, len);
senders.insert(ins);
}
int num = contacts.size();
set<string>::iterator it;
for (it = senders.begin(); it != senders.end(); ++it) {
if (contacts.find(*it) != contacts.end()) {
contacts.erase((*it));
}
}
cout << contacts.size() << endl;
}
return 0;
}
相关文章推荐
- sicily 1194 Message Flood (STL的map和set应用练习)
- Sicily 1194 Message Flood
- sicily--1194. Message Flood
- Sicily 1194 Message Flood
- sicily 1194. Message Flood
- set容器的使用-sicily 1194
- 1194. Message Flood
- sicily 1194 message blood 之失败篇
- sicily 1194
- sicily 1194 message blood之通过篇
- 1194 . Message Flood
- Sicily 1194. Message Flood 排序+二分
- 1194. Message Flood
- Sicilly 1194 Message Flood(字典树+搜索)
- Sicily 1194
- 1194: [HNOI2006]潘多拉的盒子
- 贪心算法之Huffman Code——来自Sicily
- 20460. 双11购物-中大sicily
- Sicily 1028. Hanoi Tower Sequence
- sicily 1006 单词变换(week 18)