First Derangement

Submit

Your name:
File:
Open code-statistics:

Language is selected by the extension of the file. See the list of supported languages to know the extension of your language.

Problem

Find the lexicographically earliest derangement of the input.

Options

exec is denied

rejudge feature is enabled

1day(s) and 1:38:28 before deadline (01/19 02:18:16 JST), all source codes will be revealed after the deadline

Sample input:_

AAAAAAAAAAAAABBBBBBCCCCCCCDDDDDDDEEEEEEEFFFFFFFFFGGGGGGGGGHHHHHHHIIIIIIIJJJJJJJJ
AAAAAAAAAABBBBBBCCCCCCCCCDDDDDDEEEFFFGGGGGGGGGHHHHHHHHHHHHHHHHHHIIIIIIIIIJJJJJJJ
AAAAAAAAAABBBBBBBBBBCCCDDDDDDDDEEEEEEEFFFFFFGGGGGGHHHHHHHHHHHHHIIIIIIIJJJJJJJJJJ
AAAAAAAAABBBBBBBBBBBBCCCCCCCCCDDDDDDDDEEEEEEFFFFFFFFGGGGGGGGGGGHHHHHHHIIIIIIJJJJ
AAAAAAAABBBBBCCCCCCCCDDDDDDDEEEEEEEEEFFFFFGGGGGGGGGGGGHHHHHHHHHIIIIIIIJJJJJJJJJJ
AAAAABBBBBBBBBBBBBBCCCCCDDDDDDEEEEEEEEFFFFFFFGGGGGGGGHHHHHHHHHIIIIIIIIJJJJJJJJJJ
AAAAAAAAAABBBBBBBBBBCCCCCCCDDDDEEFFFFFFFFFFFFGGGGGGHHHHHHHHHHHIIIIIIIIJJJJJJJJJJ
AAAAABBBBBBBBCCCCCCCCCCCCCDDDDDDDDEEEEEFFFFGGGGGGGGGHHHHHHHHHIIIIIIIJJJJJJJJJJJJ
AAAAAAAAAAABBBBBBBBBCCCCCCCCCDDDDDDDDDDDDDEEEEFFFFFFFFFFFFFGGGGGGGGGGHHHHHHIIJJJ
AAAAAABBBBBBBBCCCCCCCCCDDDDDDEEEEEEEFFFFFFFFGGGGGGGGGGGGGGHHHHHHHIIIIIIIIJJJJJJJ
AAAAAAAABBBBBBBBCCCCCCCCCCCCDDDDDDDEEEEEEEFFFFFFGGGGGGHHHHHII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itchs1011.09012022/01/16 14:36:590B / 45B / 53B
2rotary-o1010.04322022/01/17 22:27:330B / 36B / 61B

Ruby2 _

RankUserSizeTimeDateStatistics
1rotary-o970.08182022/01/17 22:20:320B / 35B / 58B
2darrenks1020.47862022/01/13 04:57:130B / 42B / 56B

Perl _

RankUserSizeTimeDateStatistics
1tails1000.05052022/01/13 11:22:470B / 32B / 65B

sed _

RankUserSizeTimeDateStatistics
1tails1970.88492022/01/17 04:02:240B / 46B / 141B

Scala _

RankUserSizeTimeDateStatistics
1rotary-o1302.64712022/01/17 21:19:210B / 79B / 42B

Language Ranking_

RankLangUserSizeScore
1Ruby2rotary-o9710000
2Perltails1009700
3Rubymitchs1019603
4Scalarotary-o1307461
5sedtails1974923

return to the top page