题目链接
#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
",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
",tot.empty()?"Vacant":tot.begin()->nm,
deper[p.dep].empty()?"Vacant":deper[p.dep].begin()->nm);
}
}
return 0;
}