#include<bits/stdc++.h>
using namespace std;
struct per {
string a;
string b;
int t;
int idx;
};
const int N = 1e5;
vector<struct per> v[N];
vector<struct per> ans;
map<string,int> mp,flag;
struct per p;
int dd,pp;
int t,s;
//判断身份是否能够给口罩
bool jg(string s,int day){
if(mp[s] == 0) return true;
if(day - mp[s] > pp) return true;
return false;
}
//判断身份证是否合法
bool check(string s){
if(s.size() != 18) return false;
for(int i=0;i<s.size();i++) if(!isdigit(s[i])) return false;
return true;
}
//排序
bool cmp(struct per a,struct per b){
if(a.t != b.t) return a.t < b.t;
return a.idx < b.idx;
}
int main(){
cin>>dd>>pp;
for(int i=1;i<=dd;i++){
cin>>t>>s;
for(int j=1;j<=t;j++){
cin>>p.a>>p.b;
int hh,mm,c;
scanf("%d %d:%d",&c,&hh,&mm);
p.t = hh*60 + mm;
p.idx = j;
if(c == 1 && !flag[p.b] && check(p.b)) {
flag[p.b] = 1;
ans.push_back(p);
}
v[i].push_back(p);
}
sort(v[i].begin(),v[i].end(),cmp);
for(int w=0;w<v[i].size() && s;w++){
string temp = v[i][w].b;
if(check(temp) && jg(temp,i)){
cout<<v[i][w].a<<" "<<v[i][w].b<<endl;
s--;
mp[temp] = i;//更新得到口罩的日期
}
}
}
for(int i=0;i<ans.size();i++){
cout<<ans[i].a<<" "<<ans[i].b<<endl;
}
return 0;
}
L2-034 口罩发放 (25 分)注释详解
于 2022-03-04 17:05:59 首次发布