Submission #4280962
Source Code Expand
Copy
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.stream.IntStream; import java.util.Arrays; import java.io.IOException; import java.io.BufferedReader; import java.io.Reader; import java.io.InputStreamReader; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top */ public class Main { public static void main(String[] args) { InputStream inputStream = System.in; OutputStream outputStream = System.out; MyInput in = new MyInput(inputStream); PrintWriter out = new PrintWriter(outputStream); BFoodsLovedByEveryone solver = new BFoodsLovedByEveryone(); solver.solve(1, in, out); out.close(); } static class BFoodsLovedByEveryone { public void solve(int testNumber, MyInput in, PrintWriter out) { int n = in.nextInt(); int m = in.nextInt(); int[] food = new int[m]; for (int i = 0; i < n; i++) { int k = in.nextInt(); for (int a : in.nextIntArray(k)) { food[a - 1]++; } } out.println(Arrays.stream(food).filter(x -> x == n).count()); } } static class MyInput { private final BufferedReader in; private static int pos; private static int readLen; private static final char[] buffer = new char[1024 * 8]; private static char[] str = new char[500 * 8 * 2]; private static boolean[] isDigit = new boolean[256]; private static boolean[] isSpace = new boolean[256]; private static boolean[] isLineSep = new boolean[256]; static { for (int i = 0; i < 10; i++) { isDigit['0' + i] = true; } isDigit['-'] = true; isSpace[' '] = isSpace['\r'] = isSpace['\n'] = isSpace['\t'] = true; isLineSep['\r'] = isLineSep['\n'] = true; } public MyInput(InputStream is) { in = new BufferedReader(new InputStreamReader(is)); } public int read() { if (pos >= readLen) { pos = 0; try { readLen = in.read(buffer); } catch (IOException e) { throw new RuntimeException(); } if (readLen <= 0) { throw new MyInput.EndOfFileRuntimeException(); } } return buffer[pos++]; } public int nextInt() { int len = 0; str[len++] = nextChar(); len = reads(len, isSpace); int i = 0; int ret = 0; if (str[0] == '-') { i = 1; } for (; i < len; i++) ret = ret * 10 + str[i] - '0'; if (str[0] == '-') { ret = -ret; } return ret; } public char nextChar() { while (true) { final int c = read(); if (!isSpace[c]) { return (char) c; } } } int reads(int len, boolean[] accept) { try { while (true) { final int c = read(); if (accept[c]) { break; } if (str.length == len) { char[] rep = new char[str.length * 3 / 2]; System.arraycopy(str, 0, rep, 0, str.length); str = rep; } str[len++] = (char) c; } } catch (MyInput.EndOfFileRuntimeException e) { } return len; } public int[] nextIntArray(final int n) { final int[] res = new int[n]; for (int i = 0; i < n; i++) { res[i] = nextInt(); } return res; } static class EndOfFileRuntimeException extends RuntimeException { } } }
Submission Info
Submission Time | |
---|---|
Task | B - Foods Loved by Everyone |
User | tanzaku |
Language | Java8 (OpenJDK 1.8.0) |
Score | 200 |
Code Size | 4318 Byte |
Status | AC |
Exec Time | 254 ms |
Memory | 28244 KB |
Judge Result
Set Name | All | Sample | ||||
---|---|---|---|---|---|---|
Score / Max Score | 200 / 200 | 0 / 0 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
All | 0_random_1, 0_random_2, 1_max_1, 1_max_2, 2_nmin_1, 3_mmin_1, 4_corner_1, 4_corner_2, 4_corner_3, 5_hand_1, 5_hand_2, 5_hand_3, sample_01, sample_02, sample_03 |
Sample | sample_01, sample_02, sample_03 |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
0_random_1 | AC | 254 ms | 25044 KB |
0_random_2 | AC | 160 ms | 25680 KB |
1_max_1 | AC | 160 ms | 26068 KB |
1_max_2 | AC | 157 ms | 26580 KB |
2_nmin_1 | AC | 165 ms | 28244 KB |
3_mmin_1 | AC | 159 ms | 26068 KB |
4_corner_1 | AC | 202 ms | 24268 KB |
4_corner_2 | AC | 151 ms | 27476 KB |
4_corner_3 | AC | 167 ms | 26068 KB |
5_hand_1 | AC | 170 ms | 25684 KB |
5_hand_2 | AC | 156 ms | 24276 KB |
5_hand_3 | AC | 155 ms | 26580 KB |
sample_01 | AC | 173 ms | 23884 KB |
sample_02 | AC | 157 ms | 26324 KB |
sample_03 | AC | 157 ms | 25808 KB |