寒假集训.ID Codes

ID Codes

Time Limit:3000MS     Memory Limit:0KB     64bit IO Format:%lld
& %llu

Submit Status

Description

 ID Codes 

It is 2084 and the year of Big Brother has finally arrived, albeit a century late. In order to exercise greater control over its citizens and thereby to counter a chronic breakdown in law and order, the Government
decides on a radical measure--all citizens are to have a tiny microcomputer surgically implanted in their left wrists. This computer will contains all sorts of personal information as well as a transmitter which will allow people‘s movements to be logged and
monitored by a central computer. (A desirable side effect of this process is that it will shorten the dole queue for plastic surgeons.)

An essential component of each computer will be a unique identification code, consisting of up to 50 characters drawn from the 26 lower case letters. The set of characters for any given code is chosen somewhat
haphazardly. The complicated way in which the code is imprinted into the chip makes it much easier for the manufacturer to produce codes which are rearrangements of other codes than to produce new codes with a different selection of letters. Thus, once a set
of letters has been chosen all possible codes derivable from it are used before changing the set.

For example, suppose it is decided that a code will contain exactly 3 occurrences of `a‘, 2 of `b‘ and 1 of `c‘, then three of the allowable 60 codes under these conditions are:

      abaabc
      abaacb
      ababac

These three codes are listed from top to bottom in alphabetic order. Among all codes generated with this set of characters, these codes appear consecutively in this order.

Write a program to assist in the issuing of these identification codes. Your program will accept a sequence of no more than 50 lower case letters (which may contain repeated characters) and print the successor
code if one exists or the message `No Successor‘ if the given code is the last in the sequence for that set of characters.

Input and Output

Input will consist of a series of lines each containing a string representing a code. The entire file will be terminated by a line consisting of a single #.

Output will consist of one line for each code read containing the successor code or the words `No Successor‘.

Sample input

abaacb
cbbaa
#

Sample output

ababac
No Successor

这道题可以偷懒用next_permutation函数直接求下一个排列6666666:
				
时间: 2024-08-29 18:01:22

寒假集训.ID Codes的相关文章

UVA - 146 - ID Codes (枚举排列)

UVA - 146 ID Codes Time Limit: 3000MS   Memory Limit: Unknown   64bit IO Format: %lld & %llu Submit Status Description It is 2084 and the year of Big Brother has finally arrived, albeit a century late. In order to exercise greater control over its ci

UVA 146 ID Codes(下一个排列)

C - ID Codes Time Limit:3000MS     Memory Limit:0KB     64bit IO Format:%lld & %llu Submit Status Appoint description:  System Crawler  (2014-05-12) Description  ID Codes  It is 2084 and the year of Big Brother has finally arrived, albeit a century l

Brute Force & STL --- UVA 146 ID Codes

 ID Codes  Problem's Link:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&category=3&problem=82&mosmsg=Submission+received+with+ID+14418598 Mean: 求出可重排列的下一个排列. analyse: 直接用STL来实现就可.自己手动写了一个,并不复杂.

POJ 1146:ID Codes

ID Codes Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 6281 Accepted: 3769 Description It is 2084 and the year of Big Brother has finally arrived, albeit a century late. In order to exercise greater control over its citizens and thereby

CSU-ACM寒假集训选拔-入门题

CSU-ACM寒假集训选拔-入门题 仅选择部分有价值的题 J(2165): 时间旅行 Description 假设 Bobo 位于时间轴(数轴)上 t0 点,他要使用时间机器回到区间 (0,?h] 中. 当 Bobo 位于时间轴上 t 点,同时时间机器有 c 单位燃料时,他可以选择一个满足 \(\lceil\frac{x}{h}\rceil\leq c\) 的非负整数 x, 那么时间机器会在 [0,?x]中随机整数 y,使 Bobo 回到 (t???y) 点,同时消耗 y 单位燃料. (其中 ?

寒假集训总结

这个寒假的集训吧,缺少了总结. 首先去了秦皇岛的几天还是挺不错的,但是人还是很懒散,没有每日做总结,导致以前会做的题目不会做.COME OJ上的视频也没有看完.秦皇岛开阔了眼界吧. 放寒假前的几天吧,都在聊天,唉,真的有时候会感到孤独... 只写了两场CF的所有题题解对的.(还缺178场) 之后回学校吧一个人在寝室就看看游戏直播的视频,嗯,挺荒废的. 寒假的收货吧,会了时间线段树,一些些STL,dp做了总结,分块+暴力的方法. 之后应该干什么呢,3月17校赛,3月底天梯,4月初浙大校赛,4月底浙

poj-1146 ID codes

Description It is 2084 and the year of Big Brother has finally arrived, albeit a century late. In order to exercise greater control over its citizens and thereby to counter a chronic breakdown in law and order, the Government decides on a radical mea

1146 ID Codes

题目链接: http://poj.org/problem?id=1146 题意: 给定一个字符串(长度不超过50), 求这个字符串的下一个字典序的字符串, 如果已经是最大字典序, 那么输出 "No successor". 分析: <algorithm>中有一个现成的next_permutation(begin, end), 对输入的字符串进行排列. 原型如下: 1 template<class BidirectionalIterator> 2 bool next

高一寒假集训总结

集训的一天 早读改前一天晚上没过的题. 上午学新课,开新的一套题,学模版优化模版.前半段总是没睡醒,将近中午时效率是一天中最高的.一般不大讨论. 下午继续做题,效率也比较高.讨论比上午多. 晚上思路很乱,而且一般都是做到一套题的后几道,进程缓慢,有些错误往往要到第二天早上才能想通. 集训之最 最有感触的一道题:家谱树.为了存人名现学关联式容器,发现大家课下确实学了不少东西,开学之后要拿更多时间读奥赛书,自学一些内容. 最佩服的一种解法:王超星的挖水井.这道题我做了很久,还是没能解决.请教王超星的