码迷,mamicode.com
首页 > 其他好文 > 详细

Gym - 100917H

时间:2016-12-22 00:04:26      阅读:261      评论:0      收藏:0      [点我收藏+]

标签:microsoft   scanf   scan   color   else   blank   begin   net   turn   

题目链接

#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
using namespace std;
struct person
{
    int dep;
    char nm[30];
    int time;
    int id;
    bool operator <(const person &oth)const
    {
        if(time!=oth.time)return time<oth.time;
        if(dep!=oth.dep)return dep<oth.dep;
        return id<oth.id;
    }
};
map<int,int>cnt;
map<int,set<person> >deper;
set<person>tot;
map<pair<int,int>,person>per;
person p;
int main()
{
    //freopen("cin.txt","r",stdin);
    int n;
    scanf("%d",&n);
    while(n--)
    {
        int t;
        scanf("%d",&t);
        if(t==1)
        {
            scanf("%d%s",&p.dep,p.nm);
            if(deper.find(p.dep)==deper.end())
            {
                deper[p.dep]=set<person>();
            }
            p.id=++cnt[p.dep];
            int day,month,year;
            scanf("%d:%d:%d",&day,&month,&year);
            p.time=year*10000+month*100+day;
            tot.insert(p);
            per[make_pair(p.dep,p.id)]=p;
            deper[p.dep].insert(p);
            printf("%s %s\n",tot.begin()->nm,deper[p.dep].begin()->nm);
        }
        else
        {
            int d,k;
            scanf("%d%d",&d,&k);
            p=per[make_pair(d,k)];
            tot.erase(p);
            deper[d].erase(p);
            printf("%s %s\n",tot.empty()?"Vacant":tot.begin()->nm,
                   deper[p.dep].empty()?"Vacant":deper[p.dep].begin()->nm);
        }
    }
    return 0;
}

 

Gym - 100917H

标签:microsoft   scanf   scan   color   else   blank   begin   net   turn   

原文地址:http://www.cnblogs.com/Ritchie/p/6209353.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!