17
Zara Elizabeth
Cooper dominant
Trong-Phe non-existent
Maya Aaraadhanaa
Albert Robert
Elizabeth Maya
Suzanne Albert
John Alberta
Cooper Elizabeth
Suzanne Alberta
Elizabeth Robert
Suzanne dominant
John recessive
John Albert
Albert Maya
Trong-Phe Aaraadhanaa
Zara dominant
Aaraadhanaa recessive
Albert dominant
Alberta dominant
Cooper dominant
Elizabeth dominant
John recessive
Maya dominant
Robert dominant
Suzanne dominant
Trong-Phe non-existent
Zara dominant
Check input and AC output for over 7,500 problems onuDebug!
I have passed the test cases you put and u debug test cases but still wrong answer dont know why? any help please?
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.TreeMap;
public class Genes {
static TreeMap<String, String> result;static TreeMap<String, String> condition;
public static void main(String[] args) throws NumberFormatException, IOException {
BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
result=new TreeMap<String,String>();
int n=Integer.parseInt(bf.readLine());
condition =new TreeMap<String,String>();
HashMap<String, parent> children= new HashMap<String,parent>();
for (int i = 0; i < n; i++) {
StringTokenizer st=new StringTokenizer(bf.readLine());
String first=st.nextToken();
String second=st.nextToken();
if(second.equals("non-existent") ||
second.equals("recessive") || second.equals("dominant")){
condition.put(first, second);
}
else{
if(children.containsKey(second)){
parent p=children.get(second);
p.m=first;
children.put(second, p);
extraCalc(second,p.f,p.m);
}
else{
parent p=new parent();
p.f=first;
children.put(second, p);
}
}
}
for(Map.Entry<String,parent> entry : children.entrySet()) {
if(!result.containsKey(entry.getKey())){
extraCalc(entry.getKey(),entry.getValue().f,entry.getValue().m);
}