Sicily 1027. MJ, Nowhere to Hide

//就是一个简单的字符串配对~~用map来解决很easy

#include <iostream>
#include <map>
#include <string>
using namespace std;
int main() {
    int n;
    while (cin>>n && n!=0) {
        string ip , name;
        string tmp;
        map<string,string> m;
        map<string,string>::iterator iter;
        map<string,string> ans;
        while(n--){
            cin>> name >> ip;
            if ((iter = m.find(ip) )!= m.end()) {
                ans.insert(make_pair(iter->second, name+"is the MaJia of "+ iter->second));
                m.erase(iter);
            }else
                m.insert(make_pair(ip, name));
        }
        for(iter = ans.begin() ; iter != ans.end(); iter++)
            cout << iter->second << endl;
        cout << endl;
    }
    return 0;
}
时间: 2024-07-29 04:59:42

Sicily 1027. MJ, Nowhere to Hide的相关文章

sicily 1027 MJ, Nowhere to Hide 字符串匹配与排序

1027. MJ, Nowhere to Hide Constraints Time Limit: 1 secs, Memory Limit: 32 MB Description On BBS, there is a familiar term called MJ (short for MaJia), which means another BBS ID of one person besides his/her main ID.These days, a lot of ACMers pour

Sicily 1027 MJ,Nowhere to Hide

1027. MJ, Nowhere to Hide Constraints Time Limit: 1 secs, Memory Limit: 32 MB Description On BBS, there is a familiar term called MJ (short for MaJia), which means another BBS ID of one person besides his/her main ID.These days, a lot of ACMers pour

SOJ 1027 MJ,Nowhere to Hide

题目大意:输入n行(id, ip)对,对同一个ip,第一次出现的ip对应的id为Main_ID, 第二次出现的ip对应的id为MJ_ID, 输出n / 2个(Main_ID, MJ_ID)对,输出格式为 MJ_ID is the MaJia of Main_ID,输出按Main_ID的字典序输出.当n为0时,输入结束. 解题思路:这是一种映射问题,用数据结构map非常合适.每次读入(id, ip) 对,检查map中是否已存在键值为ip的键,若不存在,则插入(id, ip)对,若存在则存放到结果映

Django项目:CRM(客户关系管理系统)--45--36PerfectCRM实现CRM用户登陆注销02

图片另存为  16*16  名字修改为      global_logo.jpg 1 /*! 2 3 *bootstrap.js 4 * 5 * Bootstrap v3.3.7 (http://getbootstrap.com) 6 * Copyright 2011-2016 Twitter, Inc. 7 * Licensed under the MIT license 8 */ 9 10 if (typeof jQuery === 'undefined') { 11 throw new E

Deep Learning Enables You to Hide Screen when Your Boss is Approaching

https://github.com/Hironsan/BossSensor/ 背景介绍 学生时代,老师站在窗外的阴影挥之不去.大家在玩手机,看漫画,看小说的时候,总是会找同桌帮忙看着班主任有没有来. 一转眼,曾经的翩翩少年毕业了,新的烦恼来了,在你刷知乎,看视频,玩手机的时候,老板来了! 不用担心,不用着急,基于最新的人脸识别+手机推送做出的BossComing.老板站起来的时候,BossComing会通过人脸识别发现老板已经站起来,然后通过手机推送发送通知“BossComing”,并且震动告

FragmentTransaction的add(),replace(),以及show(),hide()

最近在做一个Android的电商App,之前一直使用FragmentTransaction的add(),hide()和show()来控制主页的显示与隐藏.最近发现一个问题,因为show()和hide() 来控制显示隐藏的话是不走Fragment的onResume方法的,而如果使用replace()的话就是全部Fragment都走onResume()方法.这就无法满足我一部分Fragment点击刷新而另一部分不刷新的要求.最后发现,通过定义两个FragmentManager和FragmentTra

(全排列)Ignatius and the Princess II -- HDU -- 1027

链接: http://acm.hdu.edu.cn/showproblem.php?pid=1027 Ignatius and the Princess II Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 5822    Accepted Submission(s): 3433 Problem Description Now our h

在Eclipse中使用SDK中的@hide函数

我们使用Eclipse进行android开发时,使用的是ADT中提供的SDK,里面是不包含@hide函数和变量的.因为android为了兼容.安全等原因,在提供SDK时,把这些函数给隐藏了.但是,很多时候,我们又需要使用这些函数,因此我们需要手动添加android SDK.例如,当我们使用AudioManager时,当需要看某种streamType是否mute时,可以调用isStreamMute(int streamType)这个方法,但是因为它是@hide的,所以我们就需要引入自己的sdk,才

HDU 1027 Ignatius and the Princess II

原题代号:HDU 1027 原题链接:http://acm.hdu.edu.cn/showproblem.php?pid=1027 原题描述: Ignatius and the Princess II Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 8415    Accepted Submission(s): 4955 Problem