GlobeX Cup '19 S1 - Planet Classification

View as PDF

Submit solution

Points: 5 (partial)
Time limit: 2.0s
Memory limit: 64M

Author:
Problem type

Andy is travelling through the galaxy. His mission is to categorize the planets that he passes. There are K types of planets. He passes by N different planets. Each of these planets can be classified as one of these K types. You would like to help Andy on his mission by programming a computer assistant for him. Whenever he passes a planet, he will tell the assistant the type of this planet. The assistant must then tell him how many previous planets are of this type. At the end of his journey, the assistant must also report the total different types of planets that he has passed by.

Input Specification

Line 1: N and K, separated by a single space.

Line 2 to N+1: ai, the type of the planet that he has passed, where i+1 is the line number.

Output Specification

Line 1 to N: bi, the number of previous planets that are of type ai, where i is the line number.

Line N+1: t, the total number of different types of planets that Andy has passed.

Constraints

1N105

1K109

1aiK

Subtasks

Subtask 1 [10%]

N1000

Subtask 2 [10%]

K106

Subtask 3 [80%]

No additional constraints.

Sample Input

Copy
5 4
1
4
4
3
4

Sample Output

Copy
0
0
1
0
2
3

Comments


  • 1
    404  commented on Nov. 3, 2021, 7:22 p.m.

    for python 3, try using a dictionary instead of a list