C. String Transformation
 
time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

You are given a string s consisting of |s| small english letters.

In one move you can replace any character of this string to the next character in alphabetical order (a will be replaced with b, s will be replaced with t, etc.). You cannot replace letter z with any other letter.

Your target is to make some number of moves (not necessary minimal) to get string abcdefghijklmnopqrstuvwxyz (english alphabet) as a subsequence. Subsequence of the string is the string that is obtained by deleting characters at some positions. You need to print the string that will be obtained from the given string and will be contain english alphabet as a subsequence or say that it is impossible.

Input

The only one line of the input consisting of the string s consisting of |s| (1 ≤ |s| ≤ 105) small english letters.

Output

If you can get a string that can be obtained from the given string and will contain english alphabet as a subsequence, print it. Otherwise print «-1» (without quotes).

Examples
input

Copy
aacceeggiikkmmooqqssuuwwyy
output
abcdefghijklmnopqrstuvwxyz
input

Copy
thereisnoanswer
output
-1
代码:
 1 #include<iostream>
2 #include<cstring>
3 #include<cstdio>
4 #include<cmath>
5 #include<algorithm>
6 #include<cstdlib>
7 using namespace std;
8 typedef long long ll;
9 const int maxn=1e5+10;
10 #define ios ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
11 int main(){
12 string s;
13 ios;
14 cin>>s;
15 int len=s.length();
16 int tmp=0;
17 for(int i=0;i<len;i++){
18 if(s[i]-'a'<=tmp){
19 tmp++;s[i]='a'+tmp-1;
20 }
21 if(tmp==26)break;
22 }
23 if(tmp==26)cout<<s<<endl;
24 else cout<<"-1"<<endl;
25 }

溜了,滚去写D的题解。

Codeforces 946 C.String Transformation的更多相关文章

  1. CCPC2018-湖南全国邀请赛 G String Transformation

    G.String Transformation 题目描述 Bobo has a string S = s1 s2...sn consists of letter a , b and c . He ca ...

  2. Codeforces 1383C - String Transformation 2(找性质+状压 dp)

    Codeforces 题面传送门 & 洛谷题面传送门 神奇的强迫症效应,一场只要 AC 了 A.B.D.E.F,就一定会把 C 补掉( 感觉这个 C 难度比 D 难度高啊-- 首先考虑对问题进 ...

  3. Codeforces 109D String Transformation 字符串 哈希 KMP

    原文链接https://www.cnblogs.com/zhouzhendong/p/CF109D.html 题目传送门 - CF109D 题意 给定两个字符串 $a,b$ ,求一组 $i,j$ 使得 ...

  4. C. String Transformation

    http://codeforces.com/problemset/problem/946/C You are given a string s consisting of |s| small engl ...

  5. CodeForces 797C Minimal string:贪心+模拟

    题目链接:http://codeforces.com/problemset/problem/797/C 题意: 给你一个非空字符串s,空字符串t和u.有两种操作:(1)把s的首字符取出并添加到t的末尾 ...

  6. Codeforces 827E Rusty String - 快速傅里叶变换 - 暴力

    Grigory loves strings. Recently he found a metal strip on a loft. The strip had length n and consist ...

  7. Codeforces 797C - Minimal string

    C. Minimal string 题目链接:http://codeforces.com/problemset/problem/797/C time limit per test 1 second m ...

  8. Codeforces Round 486C - Palindrome Transformation 贪心

    C. Palindrome Transformation time limit per test 1 second memory limit per test 256 megabytes input ...

  9. codeforces 825F F. String Compression dp+kmp找字符串的最小循环节

    /** 题目:F. String Compression 链接:http://codeforces.com/problemset/problem/825/F 题意:压缩字符串后求最小长度. 思路: d ...

随机推荐

  1. 私有DockerHub搭建

    docker简介 一个开源的应用容器引擎,可以用来打包程序,可以包入依赖环境,这样只需要提供docker image即可,类似于虚拟机,但是更轻量级. 几个概念: Paas,platform as a ...

  2. php 计算当天凌晨时间戳 以及获取其他常用时间戳

    php 计算当日凌晨时间戳 以及获取其他常用时间戳(持续补充中...) 获取当天凌晨时间戳: echo strtotime(date('Y-m-d')); 以下再列举一些获取其他常用时间戳的方法 获取 ...

  3. 用decimal模块增加python的浮点数精度

    浮点数python默认是17位精度,也就是小数点后16位(16位以后的全部四舍五入了),虽然有16位,但是这个精度越往后越不准. 如果有特殊需求,需要更多的精度,可以用decimal模块,通过更改其里 ...

  4. 利用for循环和range输出9 * 9乘法口诀表

    li = [2, 3, 4, 5, 6, 7, 8, 9, 10] for i in li: for j in range(1, i): print('{0} * {1} = {2}'.format( ...

  5. 【LVS】简介与说明

    一.IPVS的三种负载均衡技术 通过NAT实现虚拟服务器(VS/NAT) 客户通过Virtual IP Address(虚拟服务的IP地址)访问网络服务时,请求报文到达调度器,调度器根据连接调度算法从 ...

  6. CODE FESTIVAL 2017 qual B

    昨晚因为有点事就去忙了,没打后悔啊 A - XXFESTIVAL Time limit : 2sec / Memory limit : 256MB Score : 100 points Problem ...

  7. WebApplicationContextUtils源码

    package org.springframework.web.context.support; import javax.servlet.ServletContext; import javax.s ...

  8. 九度oj 题目1188:约瑟夫环

    题目描述: N个人围成一圈顺序编号,从1号开始按1.2.3......顺序报数,报p者退出圈外,其余的人再从1.2.3开始报数,报p的人再退出圈外,以此类推.    请按退出顺序输出每个退出人的原序号 ...

  9. 【bzoj1283】序列 线性规划与费用流

    题目描述 给出一个长度为 的正整数序列Ci,求一个子序列,使得原序列中任意长度为 的子串中被选出的元素不超过K(K,M<=100) 个,并且选出的元素之和最大. 输入 第1行三个数N,m,k. ...

  10. C# Settings.settings的用处

    1.定义 在Settings.settings文件中定义配置字段.把作用范围定义为:User则运行时可更改,Applicatiion则运行时不可更改.可以使用数据网格视图,很方便: 2.读取配置值 t ...