<PREV Problem:
NEXT>
Solved by 722 users: ...
UserDateAttemptTimeCMSC
old131 jan 2007C++700.0132 
Vintik13 apr 2006C++300.0133 
Vintik13 apr 2006C++400.0133 
asp18 jul 2007C++400.0134 
asp18 jul 2007C++500.0134 
Routers14 nov 2006C++800.0134 
old113 apr 2006C++500.0135 
chexi22 oct 2006C++100.0136 
head04 dec 2006C++100.0136 
chexi24 oct 2006C++400.0136 
Routers24 oct 2006C++500.0136 
chexi24 oct 2006C++500.0136 
Routers24 oct 2006C++600.0136 
asp18 jul 2007C++600.0136 
Vintik13 apr 2006C++100.0137 
asp18 jul 2007C++200.0137 
adamant10 dec 2014C++200.0138 
VArt01 feb 2008C++600.0138 
karthiekc11 mar 2012C++3300.0138 
karthiekc11 mar 2012C++3400.0138 
karthiekc26 jul 2014C++4000.0138 
asp18 jul 2007C++300.0139 
fetetriste15 nov 2007C++1500.0139 
Languages
C++
382
FPC
162
C
98
Java
36
Kylix
34
Python
8
Ruby
7
Lua
1
Perl
1
 > 
 > 
 > 
 > 
 > 
 > 
 > 
 > 
 > 
 > 

Next word

Time limit = 2 second(s)

Somewhere in the world exist L ( L ≤ 200 ) cards, each of them has some latin letter written on it. This cards are put together to form a word of length L. The problem is to find the next word in the lexicographical order which can be formed of all those cards.

Input. Word of latin letters in the lower case.

Output. Next (in lexicographical order) word.

If the required word can not be found, output 'no word'.

Input#1
abca
Output#1
acab

Input#2
aaa

Output#2
no word

Author:
Kvasov Igor, folklore

<PREV | Problem set | Search related messages | NEXT>


© acm.mipt DevGroup
The page was generated in 220ms

SW soft NIX
ID = 3.235.66.217