标签:std img spl stl display als 数组 erase 整数
1 5 xixi haha gege hehe wuwu 10 xixi haha gege hehe wuwu wuwuhehe hehewuwu jiji xiaoming gegehehe
Lang Li Ge Lang Lang Li Ge Lang Lang Li Ge Lang Lang Li Ge Lang Lang Li Ge Lang
这是一个模拟题,用STL,set集合去保存就好了,注意吃藕群众,一开始没有注意,仔细看题。然后,这种最好不要自己用二维字符数组去模拟,代码会很长,不好维护。
1 #include<bits/stdc++.h> 2 3 using namespace std; 4 5 int main(){ 6 // ios::sync_with_stdio(false); 7 // cout.tie(NULL); 8 9 set<string> hotel_now; 10 char strs[101][101]; 11 set<string> hotel_history; 12 int n, m, k; 13 string name; 14 while (~scanf("%d", &n)) { 15 16 hotel_now.clear(); hotel_history.clear(); 17 int size = 0; 18 19 for (int i = 0; i < n; i++) { 20 scanf("%d", &m); 21 for (int j = 0; j < m; j++) { 22 scanf("%s", strs[j]); 23 name = strs[j]; 24 hotel_now.insert(name); 25 hotel_history.insert(name); 26 } 27 if (hotel_now.size() == size) { 28 for (int j = 0; j < m; j++) { 29 name = strs[j]; 30 hotel_now.erase(name); 31 } 32 } 33 size = hotel_now.size(); 34 } 35 scanf("%d", &k); 36 for (int i = 0; i < k; i++) { 37 scanf("%s", strs[0]); 38 name = strs[0]; 39 if (hotel_now.find(name) != hotel_now.end()) cout << "Lang Li Ge Lang" << endl; 40 else { 41 if (hotel_history.find(name) != hotel_history.end()) cout << "Check Out" << endl; 42 } 43 } 44 } 45 return 0; 46 }
标签:std img spl stl display als 数组 erase 整数
原文地址:https://www.cnblogs.com/gznb/p/11208083.html