C~K recruiting relatives

Time Limit: 1000 ms Memory Limit: 65536 KiB

Problem Description
C~K, a single aristocrat, is fed up with living alone, he wants to find a girlfriend to study with him, so he sent a notice to the whole country to recruit relatives.
Because C~K is very good, many girls all over the country have sent their registration forms. C~K's subordinate DaYu helps him organize these registration forms. The registration form is at the top.
For the sake of fairness, C~K decided to look at these registration forms in the order submitted by the girls, and C~K doesn't eat coriander, and doesn't like people who eat coriander, so he doesn't want to see the registration form for people who like coriander. And some girls are very impatient and have submitted multiple registration forms, and these duplicate registration forms should be removed.
C~K asked DaYu to rearrange the registration forms, but there were too many registration forms for DaYu to sort out, so DaYu came to help you.

The registration form submitted by the input
girl, the content is the girl's name, the girl's self-introduction, and whether the girl likes to eat coriander (True or False). The same registration form only keeps the one that appears for the first time.

Output
C~K Expected to see the registration form sequence

Sample Input
Fengjie I love you False
Hibiscus I want to be with you False
dayu Maybe this is love False
milk tea hehe True
Hibiscus I want to be with you False
Sample Output
dayu Maybe this is love False
Hibiscus I want to be with you False
Feng sister I love you False
Hint
When reader.hasNext() == false, the input ends

Source
MeiK


import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner ss = new Scanner(System.in);
        LinkedList<String> s = new LinkedList<String>();
        while (ss.hasNext()) {
            String str;
            str = ss.nextLine();
            String fs[] = str.split(" ");
            if (fs[2].equals("False")) {
                if (!s.contains(str)) {
                    //s.push(str);使用push不对;
                    s.add(str);
                }
            }

        }
        for (int i = s.size() - 1; i >= 0; i--) {
            System.out.println(s.get(i));
        }
        ss.close();
    }
}

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325899968&siteId=291194637