SBANK - Sorting Bank Accounts


In one of the internet banks thousands of operations are being performed every day. Since certain customers do business more actively than others, some of the bank accounts occur many times in the list of operations. Your task is to sort the bank account numbers in ascending order. If an account appears twice or more in the list, write the number of repetitions just after the account number. The format of accounts is as follows: 2 control digits, an 8-digit code of the bank, 16 digits identifying the owner (written in groups of four digits), for example (at the end of each line there is exactly one space):

30 10103538 2222 1233 6160 0142 

Banks are real-time institutions and they need FAST solutions. If you feel you can meet the challenge within a very stringent time limit, go ahead! A well designed sorting algorithm in a fast language is likely to succeed.

Input

t [the number of tests <= 5]
n [the number of accounts<= 100 000]
[list of accounts]
[empty line]
[next test cases]

Output

[sorted list of accounts with the number of repeated accounts]
[empty line]
[other results]

Example

Input:
2
6
03 10103538 2222 1233 6160 0142 
03 10103538 2222 1233 6160 0141 
30 10103538 2222 1233 6160 0141 
30 10103538 2222 1233 6160 0142 
30 10103538 2222 1233 6160 0141 
30 10103538 2222 1233 6160 0142 

5
30 10103538 2222 1233 6160 0144 
30 10103538 2222 1233 6160 0142 
30 10103538 2222 1233 6160 0145 
30 10103538 2222 1233 6160 0146 
30 10103538 2222 1233 6160 0143 

Output:
03 10103538 2222 1233 6160 0141 1
03 10103538 2222 1233 6160 0142 1
30 10103538 2222 1233 6160 0141 2
30 10103538 2222 1233 6160 0142 2

30 10103538 2222 1233 6160 0142 1
30 10103538 2222 1233 6160 0143 1
30 10103538 2222 1233 6160 0144 1
30 10103538 2222 1233 6160 0145 1
30 10103538 2222 1233 6160 0146 1

hide comments
baadshah_: 2016-07-12 15:12:57

AC in one go!!
Used SET and MAP

sonali9696: 2016-06-27 10:20:38

AC in one go! But learnt a lot! Simply used qsort and array. No STL. Feeling awesome! :D

manish3749: 2016-06-24 20:58:11

in one go.
used nly string vector and its sort function

mkfeuhrer: 2016-06-06 03:23:42

map....stl :-) AC 1 go :-)

akshayvenkat: 2016-06-02 11:56:24

string bubble sort-> TLE
BST inorder -> AC 0.45
MAP -> AC 0.50

Last edit: 2016-09-17 20:35:49
Luis Herrera: 2016-05-25 05:03:24

Nice problem, you can use a set and map to solve it.

ranjanakash166: 2016-05-16 07:23:22

USED MAP IN C++ STL.DONT FORGET TO CLEAR THE MAP AFTER EACH TEST CASE.
IT GAVE ME 8 WA!!!

girishkumaral: 2016-05-03 18:27:20

Array[0-100]->(10103538, (BST(BST(BST()))) ??

Siddharth Singh: 2016-03-26 07:20:35

Same Program Showed CE In C++14 And Runned In C++ ~_~
Use Scanf("%lld\n",&n);
else you'll get tons of WAs

abc_c: 2016-03-11 10:55:59

Bad Input Format !!
Used scanf("%d", &n) to get no. of Accounts, got 5 WAs
Used scanf("%d\n", &n) ,got AC >:O

Last edit: 2016-03-11 11:13:17

Added by:mima
Date:2004-06-01
Time limit:7s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: NODEJS PERL6 VB.NET
Resource:-