• 湖南一师大酒店


    湖南一师大酒店

    Time Limit : 3000/1000ms (Java/Other)   Memory Limit : 65535/32768K (Java/Other)
    Total Submission(s) : 86   Accepted Submission(s) : 16

    Font: Times New Roman | Verdana | Georgia

    Font Size: ← →

    Problem Description

    维也纳在湖南第一师范学院旁边开分店了,这次叫作湖南一师大酒店。然后同学A就想去体验下新酒店怎么玩。

    现在有如下规则
    1.一群吃瓜群众中,如果都没去登记住房,则他们都要入住
    2.一群吃饼群众中,所有人都入住了,则他们都要退房
    3.一群吃藕群众中,有的人已经入住了,有的人没入住,那么没入住的都入住,入住了的还入住

    接下来有K次查询
    假如查询的人已经退房了,请输出"Check Out"
    假如查询的人正在住房,请输出"Lang Li Ge Lang"
    假如查询的人没有出现过,则没有输出

    Input

    本题有多个测试用例

    用例的第一行输入一个整数n,代表有n次住房信息(1≤n≤5000)

    第2~n+1行,每行一个整数m,代表有m个人入住,接下来m个人的名字(可见字符组成,中间没空格,没换行)(1≤m≤100,名字长度小于100)

    第n+2行,一个整数k,代表k次查询(1≤k≤10000)

    接下来有k次查询,按照规则输入相应的字符串

    Output

    假如查询的人已经退房了,请输出"Check Out",假如查询的人正在住房,请输出"Lang Li Ge Lang",假如查询的人没有出现过,则没有输出。

    Sample Input

    1
    5 xixi haha gege hehe wuwu
    10
    xixi 
    haha 
    gege
    hehe
    wuwu
    wuwuhehe
    hehewuwu
    jiji
    xiaoming
    gegehehe

    Sample Output

    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 }
    View Code
  • 相关阅读:
    SNMP概述–运维必知的协议基础
    关于多线程情况下Net-SNMP v3 版本导致进程假死情况的跟踪与分析
    关于snmp octet string和普通string问题
    SVN状态说明
    SNMP mib文件说明
    Linux之 proc文件系统
    django .all .values .value_list 数据库获取数据
    Django form验证
    JSONP实现
    iframe和form表单实现ajax请求上传数据
  • 原文地址:https://www.cnblogs.com/gznb/p/11208083.html
Copyright © 2020-2023  润新知