感觉其实没问题了,但是只有70分,而且试过很多用例都没问题,请各位大佬指点。
package ccf;
import java.util.Scanner;
import java.util.Vector;
public class Main14 {
public static void main(String args[]) {
Scanner reader=new Scanner(System.in);
int p=reader.nextInt();
String[] a=new String[p];
String[] m=new String[5];
int[] tag=new int[p];
String[] tagname=new String[p];
for(int i=0;i<p;i++)
{
a[i]=reader.next();
m=a[i].split(":");
tagname[i]=m[0];
if(a[i].indexOf(':')==-1)
{
tag[i]=0;//无等级规则
}
else
{
int q=Integer.parseInt(m[1]);
tag[i]=q;
}
}
//for(int j=0;j<p;j++)
//{
// System.out.println(tag[j]);
//}
int r=reader.nextInt();
//System.out.println(r);
int[] juesenum=new int[r];
String[][] name=new String[r][2];
reader.nextLine();
//Vector<String>[] e=new Vector[r];
//for(int j=0;j<r;j++)
//{
// e[j]=new Vector<String>();
//}
for(int i=0;i<r;i++)
{
String x=reader.nextLine();
String[] d=x.split(" ",3);
//System.out.println(d[0]);
int xx=Integer.parseInt(d[1]);
juesenum[i]=Integer.parseInt(d[1]);
name[i][0]=d[0];
name[i][1]=d[2];
//System.out.println(name[i][1]);
}
int u=reader.nextInt();
//System.out.println(u);
String[][] people=new String[u][2];
int[] peoplenum=new int[u];
reader.nextLine();
for(int j=0;j<u;j++)
{
String xString=reader.nextLine();
String[] d=xString.split(" ",3);
int xx=Integer.parseInt(d[1]);
peoplenum[j]=Integer.parseInt(d[1]);
people[j][0]=d[0];
people[j][1]=d[2];
}
int q=reader.nextInt();
String[] findname=new String[q];
String[] findlevel=new String[q];
for(int k=0;k<q;k++)
{
findname[k]=reader.next();
findlevel[k]=reader.next();
}
//for(int k=0;k<q;k++) {
//System.out.println(findlevel[k]);}
String[] fin=new String[u];
for(int i=0;i<u;i++)
fin[i]="";
for(int i=0;i<u;i++)
for(int j=0;j<r;j++)
{
if(people[i][1].indexOf(name[j][0])!=-1)
fin[i]=fin[i]+name[j][1]+" ";
}
//for(int k=0;k<u;k++)
//System.out.println(fin[k]);
int fromname=0;
int quanxian;
int flag=0;
//System.out.println(p);
for(int i=0;i<q;i++)
{
int flag2=-1;
int flag3=-1;
for(int tt=0;tt<u;tt++)
{
if(findname[i].equals(people[tt][0]))
{
flag2=1;
break;
}
}
for(int coco=0;coco<p;coco++)
{
String[] cc=findlevel[i].split(":");
if(tagname[coco].equals(cc[0]))
{
flag3=1;
break;
}
}
if(flag2==1&&flag3==1)
{String mubiao;
for(int j=0;j<p;j++)
if(findlevel[i].indexOf(tagname[j])!=-1)
{flag=tag[j];break;}
if(flag==0)
{
for(int k=0;k<u;k++)
{
if(findname[i].indexOf(people[k][0])!=-1)
{
if(fin[k].indexOf(findlevel[i])!=-1)
System.out.println(true);
else
System.out.println(false);
break;
}
}
}
else
{
//有权限查询
int max2=-10;
if(findlevel[i].indexOf(":")!=-1)
{
String[] shishi=findlevel[i].split(":");
for(int k=0;k<u;k++)
{
if(findname[i].indexOf(people[k][0])!=-1)
{
//if(fin[k].indexOf(findlevel[i])!=-1)
// System.out.println(true);
//else
// System.out.println(false);
String []duanduan=fin[k].split(" ");
for(int hh=0;hh<duanduan.length;hh++)
{
if(duanduan[hh].indexOf(shishi[0])!=-1)
{
String[] qq=duanduan[hh].split(":");
int oo=Integer.parseInt(qq[1]);
if(max2<oo)
max2=oo;
}
}
}
}
int other=Integer.parseInt(shishi[1]);
if(other<=max2)
System.out.println(true);
else
System.out.println(false);
}
else//无权限查询
{
int max=-100;
for(int k=0;k<u;k++)
{
if(findname[i].indexOf(people[k][0])!=-1)
{
String[] honghong=fin[k].split(" ");
for(int dd=0;dd<honghong.length;dd++)
{
if(honghong[dd].indexOf(findlevel[i])!=-1)
{
String[] ww=honghong[dd].split(":");
int wo=Integer.parseInt(ww[1]);
if(max<wo)
max=wo;
}
}
if(max==-100)
System.out.println(false);
else
System.out.println(max);
}
}
}
}
}
else
System.out.println(false);
}
//System.out.println(q);
}
}