Submit | All submissions | Best solutions | Back to list |
PCPC12D - New Strategy |
Meeda will compete this year in the ACM-ICPC world finals, but he is a crazy guy, he created a new strategy to attack the problem set. His new strategy is to solve the problems according to their names. He’ll sort the problem set according to the following rules.
- Remove all whitespace characters from the problem names.
- Replace any capital letters with the corresponding small one. i.e ‘A’ will be ‘a’.
- count the occurrence of each character.
- Problem A comes before problem B, if A contains lexicographically smaller characters more than B i.e A = “cba” comes before B = “bc” because A contains 1 'a' and B contains 0 'a'.
But as you may know that meeda is a very lazy guy and he needs to train for this strategy before the world finals, so he needs your help to write an efficient program to help him in the training.
Input
The first line of the input contains T, number of test cases, each test case starts with an integer n (0 < n < 1000) number of problems, follow n lines each containing string s. The ith line is the name of the ith problem. s will be a sequence of characters (a-z, A-Z or any white space character), length of s is less than 200 characters.
Output
First line of each test case should contains “case: ” without double quotes followed by the test case number starting from 1, then follow problem names sorted as described above.
Input 2 2 abc ab 4 bcsaasd dbasaaaa azzz bayy Output case: 1 abc ab case: 2 dbasaaaa bcsaasd bayy azzz
note: sorry for the wrong description.
Max length is 200.
Added by: | abdelkarim |
Date: | 2012-12-28 |
Time limit: | 2s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ASM64 |
Resource: | The First Palestinian Collegiate Programming Contest |
hide comments
|
|||||
2019-06-20 16:27:51
How on earth I am still geting WA in submission 23949785 ? Is there something missing in the description? |
|||||
2016-11-09 22:22:28 :D
It's always tricky when problem requires to to read to newline, byt also leave other white-spaces in input string. Those could result from coding or input formatting. In this case there seems to be no issues. If you have trouble here's a hint: I used scanf("%d\n", &a) for numbers and gets(str) for strings. |
|||||
2014-08-23 07:55:06 Swapnil Jain
What would be the output of this test case? 1 4 abc ABC CBA cba |
|||||
2013-06-26 06:44:59 !!.Nginx.!!
AC in 1st attempt.. ;) |
|||||
2013-06-23 20:51:13 Abhishek
the names printed at the last should be original ones(i.e without removal of spaces and any changes) |
|||||
2013-06-12 17:06:01 vishal chaudhary
m getting WA...is there blank line after each line of input..? i m using getline so my code works if there r no blank lines..can anybody suggest input format which is independent of blank line..thanks.. |
|||||
2013-06-26 00:19:43 যোবায়ের
got so many wa in a virtual contest because of wrong constraint statements |
|||||
2013-01-15 15:34:17 Vikas Kushwaha
pheww..AC,after so many WA's. |
|||||
2013-01-15 15:34:17 Aditya Pande
Cost me so many WA.....:( Last edit: 2013-01-03 17:17:29 |
|||||
2013-01-15 15:34:17 (Tjandra Satria Gunawan)(曾毅昆)
max length of s is 200, description of this problem is wrong.. and again, I think Pyramid cluster is better for this problem... >>Unfortunately , i can't change the cluster now :( . Last edit: 2013-01-03 13:31:51 |