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
dwij28:
2016-01-23 16:19:06
Python users should use defaultdict in case of TLE.. |
|
Mohit Rathore:
2016-01-19 15:38:44
Piece of cake for Python users. ;) |
|
Nguyen Cuong:
2016-01-16 07:46:48
@Shantanu Banerjee: thanks for your advice :) |
|
dokz:
2016-01-15 09:29:20
C# LINQ Enumerable.Range - Select - Group - Order, one line solution easy AC. |
|
nonushikhar:
2015-12-31 08:56:27
solved without using maps .....just used array and qsort |
|
Shantanu Banerjee:
2015-12-25 19:03:41
If you will use C++ STL, you won't be able to learn new things.
|
|
bunnycoder:
2015-12-12 06:09:00
learnt a new thing about taking inputs |
|
Sarthak Munshi:
2015-10-14 21:21:00
Simple STL Maps . |
|
jarvis:
2015-09-04 19:04:24
left this que 3 months ago when dint knew about STL....
|
|
topke:
2015-08-28 21:38:16
To be honest this input is broken. I didn't know I need to use scanf("%d\n" , &n) to get number of bank accounts and that costed me lots of WA-s. In the end i looked it up on the forums. Can someone explain me the reason behind this? |
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: | - |