题解
1.身份证号长度必须为18,且均为数字
2.如果申请人身份证合法,且身体状况为1,就把他放进ans2,(申请顺序)
3.身份证一定不同,姓名可能相同
4.得到口罩的输出是发放顺序
code
#include<bits/stdc++.h>
using namespace std;
map<string,int> exist;
map<string,string > fa;
map<string,int> gender;
set<string> q;
void ss1(string now,int len)
{
if(len>=5) return;
q.insert(now);
if(fa[now]!="-1") ss1(fa[now],len+1);
}
int ss2(string now,int len)
{
if(len>=5) return 0;
if(q.count(now)) return 1;
else return ss2(fa[now],len+1);
}
int main()
{
int n;
cin>>n;
for(int i=1;i<=n;i++)
{
string s1,s2;
cin>>s1>>s2;
exist[s1]=1;
int len=s2.length();
if(s2[len-1]=='n')
{
fa[s1]=s2.substr(0,len-4);
gender[s1]=1;
}
else if(s2[len-1]=='r')
{
fa[s1]=s2.substr(0,len-7);
gender[s1]=0;
}
else if(s2[len-1]=='m')
{
gender[s1]=1;
fa[s1]="-1";
}
else
{
gender[s1]=0;
fa[s1]="-1";
}
}
int t;
cin>>t;
while(t--)
{
string s1,s2,s3,s4;
cin>>s1>>s2>>s3>>s4;
if(!exist[s1]||!exist[s3]) puts("NA");
else if(gender[s1]==gender[s3]) puts("Whatever");
else
{
ss1(s1,1);
if(ss2(s3,1)) puts("No");
else puts("Yes");
}
q.clear();
}
return 0;
}
标签:口罩,int,s2,s1,len,fa,L2,gender,034
From: https://www.cnblogs.com/pure4knowledge/p/18146617