oj mrJudge
Toggle navigation
  • Login
    • Forget Password
      Login
User Image

Hello, Stranger

Guest
  • Analysis Mode
  • Problems
    • All Problems
    • Latest Problems
  • Join Us Now
  • Registration
  • Contact Us
  • Infomation
  • About
    • Terms of Use
    • Technical Specifications
    • Credits

crunchy Batch , stdin/stdout

Registered Users Only

Please login to utilize this feature.

Do note that this website only supports submissions in C++.

crunchy.html

Some people claim that a word A is crunchier than a word B if the first letter of A that differs from B is smaller ('smaller' means an earlier letter in the alphabet, eg. b is smaller than c, g is smaller than z).

You are given N words, each of length K. You can join all of them together in any order you like to form a long word. Output the crunchiest word you can form.

Input

On the first line are integers N and K (1 ≤ N ≤ 20,000, 1 ≤ K ≤ 10).

Each of the next N lines contains a word of length K consisting only of the letters a..z.

Output

On the first and only line, output the crunchiest word you can form.

Grading

For 30% of test cases, N ≤ 1,000.

Sample Input 1

3 3
ghi
abc
qwe

Sample Output 1

abcghiqwe

Explanation for Sample Output 1

There are 6 possible words you can form: ghiabcqwe, ghiqweabc, abcghiqwe, abcqweghi, qweabcghi, qweghiabc. The 4 words that start with g or q are less crunchy than the 2 that start with a. Between "abcghiqwe" and "abcqweghi", the first letter that differs is the fourth one, and g is smaller than q, hence "abcghiqwe" is crunchier.

Tags

Sorting, NOI 2010 Selection Test

Subtasks and Limits

Subtask Score #TC Time Memory Scoring
13061s32MBMinimum
270141s32MBMinimum
3011s32MBMinimum

Judge Compile Command

g++-8 ans.cpp -o crunchy -Wall -Wshadow -static -O2 -lm -m64 -s -w -std=gnu++17 -fmax-errors=512

Accepted Submissions

subIDUserTimeMax Time

Past Submissions

subIDUserTimeScore
mrJudge 09.05.20
Copyright © 2020 mrJudge. All rights reserved.