L1-020 帅到没朋友_java

L1-020 帅到没朋友_java_第1张图片

输入样例1:

3
3 11111 22222 55555
2 33333 44444
4 55555 66666 99999 77777
8
55555 44444 10000 88888 22222 11111 23333 88888

输出样例1:

10000 88888 23333

输入样例2:

3
3 11111 22222 55555
2 33333 44444
4 55555 66666 99999 77777
4
55555 44444 22222 11111

输出样例2:

No one is handsome

 java

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        boolean[] flag = new boolean[100001];
        boolean F = true;
        int n = Integer.parseInt(reader.readLine());
        for (int i = 0; i < n; i++) {
            String[] str = reader.readLine().split(" ");
            int m = Integer.parseInt(str[0]);
            if (m != 1)
                for (int j = 1; j <= m; j++)
                    flag[Integer.parseInt(str[j])] = true;
        }
        n = Integer.parseInt(reader.readLine());
        String[] str = reader.readLine().split(" ");
        for (int i = 0; i < n; i++) {
            if (!flag[Integer.parseInt(str[i])]) {
                if (F == false)
                    System.out.print(" ");
                System.out.printf(str[i]);
                flag[Integer.parseInt(str[i])] = true;
                F = false;
            }
        }
        if (F)
            System.out.println("No one is handsome");
    }
}

你可能感兴趣的:(pta,java,开发语言)