oj mrJudge
Toggle navigation
  • Login
    • Forget Password
      Login
User Image

Hello, Stranger

Guest
  • Analysis Mode
  • Problems
    • All Problems
    • Latest Problems
  • Join Us Now
  • Registration
  • Contact Us
  • Infomation
  • About
    • Terms of Use
    • Technical Specifications
    • Credits

cnyfood Batch , stdin/stdout

Registered Users Only

Please login to utilize this feature.

Do note that this website only supports submissions in C++.

cnyfood.html

Problem Description

Rar the Cat has N tables of Chinese New Year food items. Table i has Mi food items on it. For convenience, each food is labelled as an integer from 0 to 109. Different food items have different labels while identical food items will have the same label.

As there can be more than 1 of the same food item on each tables, Rar the Cat wants to know how many distinct food items there are on each table. Also, Rar the Cat wants to know how many distinct food items there are in all the N tables combined.

Limits

For all testcases, 0 ≤ Ai ≤ 109.

Subtask 1 (39%): N = 1, 0 ≤ M1 ≤ 106.

Subtask 2 (12%): 1 ≤ N ≤ 100000, Sum of Mi ≤ 106. However, if a food appears in one table, it will not appear in all other tables. Still, there can be multiple copies of the same food on that single table.

Subtask 3 (49%): 1 ≤ N ≤ 100000, Sum of Mi ≤ 106.

Subtask 4 (0%): Sample Testcases.

Input

The first line of input will contain one integer, N.

N lines will follow. The first integer of the ith line is Mi. Then, Mi integers will be provided in the same line. Each of these integers is between 0 and 109, representing a food item.

Output

You are to output N+1 integers, one on each line.

The first N integers should be the number of distinct food items there are on each table. The ith of these lines should contain the answer to the ith table.

The last integer should be the number of distinct food items there are on all N tables combined.

Sample Testcase 1

Input

3
5 1 2 3 2 3
5 4 5 5 4 4
3 6 6 6

Output

3
2
1
6

Sample Testcase 2

Input

3
5 1 2 3 4 5
4 1 2 2 6
7 1 6 2 5 10 2 1

Output

5
3
5
7

Explanation

Table 1 has 5 distinct food items: 1, 2, 3, 4, 5.

Table 2 has 3 distinct food items: 1, 2, 6.

Table 3 has 5 distinct food items: 1, 2, 5, 6, 10.

Table 1 to 3 combined have 7 distinct food items: 1, 2, 3, 4, 5, 6, 10.

Tags

Data Structure

Subtasks and Limits

Subtask Score #TC Time Memory Scoring
13963s256MBMinimum
212123s256MBMinimum
349223s256MBMinimum
4023s256MBMinimum

Judge Compile Command

g++-8 ans.cpp -o cnyfood -Wall -Wshadow -static -O2 -lm -m64 -s -w -std=gnu++17 -fmax-errors=512

Accepted Submissions

subIDUserTimeMax Time

Past Submissions

subIDUserTimeScore
mrJudge 09.05.20
Copyright © 2020 mrJudge. All rights reserved.