Back to Category
d251: [12.09] B - Finding unique active users
Keyword:

Difficulity: N/A | Test Data Sets: 1 (Hidden) | Judging: Traditional Judge
Accepted : 5 Times | Submit :11 Times | Clicks : 463
Accepted : 4 Users | Submit : 4 Users | Accepted rate : 100%
Time Limit :2000 ms | Memory Limit : 64000 KBytes
Update : 2012-11-01 21:57

Content:

A manager who runs a web 2.0 service wants to know the number of unique active users of his/her web site so that he/she can measure the popularity of the web site. When a user visits a page of the web site or performs an action, the server records the user’s id in a log. At the end of a day, the manager can retrieve the information inside the log and count the number of unique active users. For example, Figure 1 shows the content of a log. 
 Figure 1
Form the log, we know there are 4 unique users (i.e., AA01, 0123, 0212, and CD26). Note that although “AA01” repeats twice, the appearance of AA01 still only be counted once because we want to obtain the number of “unique” user IDs.
 
Given a log, please write a program that can rapidly count the number of unique users. 
 

Technical Specifications

The number of items in a log would be smaller than or equal to 2, 000, 000. 

Input:

The first line of the input file contains an integer indicating the number of test cases to follow. Each test case is ended with a line of “-1”. There are N lines (0 < N ≤ 2000000) in a test case. Each line indicates a user ID. A user ID is a 4-character string. Each character of a user ID can be a single-digit number between 0 and 9 or any letter within the range of a capital A to a capital Z .

Output:

For each test case, output the number of unique active users in one line.

Sample Input:help

若題目沒有特別說明,則應該以多測資的方式讀取,若不知如何讀取請參考 a001 的範例程式。
2
AA01
0213
AA01
0212
CD26
-1
AA01
0123
0000
0000
0000
0000
-1

Sample Output :

4
3

Hint :

click here to download the problem solving hint

Author :


  Solve it!   Status Forum

C
C++
JAVA
PASCAL
50040. yanzi12321
(86ms, 976KB, 744B)

Program running time may be affected by various factors. Check server system environment information here