C~K is looking for a girlfriend! ! !
Problem Description
As 11.11 is approaching, C~K sees that all the friends around her have taken off their orders or are about to do so. C~K also wants to find a girlfriend (I heard that the country will assign them?). MeiK heard about this and
said that C~K was finally enlightened, so he compiled a list of candidates for C~K. But C~K has the height range and age limit of the girls he is attracted to, so he wants
to filter out the information of the eligible girls, but this is difficult for C~K, it is about C~K's happiness, you can help him?
ps: Because MeiK is stupid, there may be duplicate information about girls in the list. If the information is duplicated, the first input is valid information.
Input
Multiple sets of inputs.
There are N people (N<100000) in the candidate list entered into MeiK in the first line.
Enter the four integers a,b,c,d on the second line. Represent the minimum and maximum height and the minimum and maximum age of C~K heart girls, respectively. (The title guarantees a<=b, c<=d)
Next, enter N lines, each line represents the information of a girl (name, height, age, contact information)
ps: Contact information no more than 11 characters.
Output
For each set of inputs, the first line outputs an n, representing the number of eligible girls.
For the next n lines, each line outputs the information of a qualified girl.
The output order is sorted by height from low to high. If the height is the same, it is sorted by age from high to bottom. If the age is also the same, it is output in the input order.
Sample Input
4 160 170 20 22 Goddess 1 161 19 11111 Goddess 2 167 20 22222 Goddess 2 167 20 22222 Goddess 3 163 21 33333
Sample Output
2 Goddess 3 163 21 33333 Goddess 2 167 20 22222
Hint
import java.util.*; class St { String name; int he, age; String tel; public St(String name, int he, int age, String tel) { super(); this.name = name; this.he = he; this.age = age; this.tel = tel; } @Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + age; result = prime * result + he; result = prime * result + ((name == null) ? 0 : name.hashCode()); result = prime * result + ((tel == null) ? 0 : tel.hashCode()); return result; } @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; St other = (St) obj; if (age != other.age) return false; if (he != other.he) return false; if (name == null) { if (other.name != null) return false; } else if (!name.equals(other.name)) return false; if (tel == null) { if (other.tel != null) return false; } else if (!tel.equals(other.tel)) return false; return true; } @Override public String toString() { return name + " " + he + " " + age + " " + tel ; } } public class Main { public static void main(String[] args) { int n, m, i, a, b, c, d; String name; int he, age; String tel; Scanner re = new Scanner(System.in); while(re.hasNext()) { n = re.nextInt(); a = re.nextInt(); b = re.nextInt(); c = re.nextInt(); d = re.nextInt(); Set<St>set = new HashSet<St>(); for(i = 0; i < n; i++) { name = re.next(); he = re.nextInt(); age = re.nextInt(); tel = re.next(); St s1 = new St(name, he, age,tel); if((s1.age>=c&&s1.age<=d)&&(s1.he>=a&&s1.he<=b)) set.add(s1); } int k = set.size(); System.out.println(k); List<St>list = new ArrayList<St>(set); Collections.sort(list, new Comparator<St>() { public int compare(St t1, St t2) { if(t1.he==t2.he) { return t2.age-t1.age; } else return t1.he-t2.he; } }); Iterator<St> it = list.iterator(); while(it.hasNext()) { System.out.println(it.next()); } } re.close(); } }