L2-2 口罩发放 (25 分)
为了抗击来势汹汹的 COVID19 新型冠状病毒,全国各地均启动了各项措施控制疫情发展,其中一个重要的环节是口罩的发放。某市出于给市民发放口罩的需要,推出了一款小程序让市民填写信息,方便工作的开展。小程序收集了各种信息,包括市民的姓名、身份证、身体情况、提交时间等,但因为数据量太大,需要根据一定规则进行筛选和处理,请你编写程序,按照给定规则输出口罩的寄送名单。

输入格式:

L2-2 口罩发放 (25 分)_i++

输出格式:
对于每一天的申请记录,每行输出一位得到口罩的人的姓名及身份证号,用一个空格隔开。顺序按照发放顺序确定。

在输出完发放记录后,你还需要输出有合法记录的、身体状况为 1 的申请人的姓名及身份证号,用空格隔开。顺序按照申请记录中出现的顺序确定,同一个人只需要输出一次。

输入样例:

4 2
5 3
A 123456789012345670 1 13:58
B 123456789012345671 0 13:58
C 12345678901234567 0 13:22
D 123456789012345672 0 03:24
C 123456789012345673 0 13:59
4 3
A 123456789012345670 1 13:58
E 123456789012345674 0 13:59
C 123456789012345673 0 13:59
F F 0 14:00
1 3
E 123456789012345674 1 13:58
1 1
A 123456789012345670 0 14:11

输出样例:

D 123456789012345672
A 123456789012345670
B 123456789012345671
E 123456789012345674
C 123456789012345673
A 123456789012345670
A 123456789012345670
E 123456789012345674

样例解释:
输出中,第一行到第三行是第一天的部分;第四、五行是第二天的部分;第三天没有符合要求的市民;第六行是第四天的部分。最后两行按照出现顺序输出了可能存在身体不适的人员。

#include<iostream>
#include<tuple>
#include<string>
#include<vector>
#include<cctype>
#include<map>
#include<set>
#include<algorithm>

using namespace std;
struct Info{
string name, num;
int condi, a,b;
};


bool cmp(Info , Info);
bool check(string);

int main(){
vector<Info> ans1,ans2;
map<string,int> mp;
set<string> tx;

int d, p;
cin >> d>> p;
for(int i = 1; i <= d; i++){
int n,m;
cin >> n >> m;
vector<Info> info;

for(int j = 1; j <= n; j++){
Info temp;
char ch;
cin >> temp.name >> temp.num >> temp.condi >> temp.a >> ch >> temp.b;
if(check(temp.num)){
temp.b = temp.b *10000+j;
info.push_back(temp);
if(temp.condi == 1 && tx.count(temp.num) == 0){
ans2.push_back(temp);
tx.insert(temp.num);
}
}
}


if(info.size() == 0){
continue;
}

sort(info.begin(), info.end(), cmp);

for(int j = 0; j < info.size(); j++){
if(m==0){
break;
}
if(mp.count(info[j].num) == 0 || mp[info[j].num] + p + 1 <= i){
ans1.push_back(info[j]);
mp[info[j].num] = i;
m--;
}

}


}


for(int i = 0; i < ans1.size(); i++){
cout << ans1[i].name << " " << ans1[i].num << endl;
}


for(int i = 0; i < ans2.size(); i++){
cout << ans2[i].name << " " << ans2[i].num << endl;
}

}

bool cmp(Info x, Info y){
return tie(x.a,x.b) <= tie(y.a, y.b);
}

bool check(string s){
bool flag = true;
if(s.length() != 18){
flag = false;
}

for(int i = 0; i < s.length(); i++){
if(!isdigit(s[i])){
flag = false;
break;
}
}

return flag;
}