ZS the Coder loves to read the dictionary. He thinks that a word is nice if there exists a substring (contiguous segment of letters) of it of length 26 where each letter of English alphabet appears exactly once. In particular, if the string has length strictly less than 26, no such substring exists and thus it is not nice.

Now, ZS the Coder tells you a word, where some of its letters are missing as he forgot them. He wants to determine if it is possible to fill in the missing letters so that the resulting word is nice. If it is possible, he needs you to find an example of such a word as well. Can you help him?

Input

The first and only line of the input contains a single string s (1 ≤ |s| ≤ 50 000), the word that ZS the Coder remembers. Each character of the string is the uppercase letter of English alphabet ('A'-'Z') or is a question mark ('?'), where the question marks denotes the letters that ZS the Coder can't remember.

Output

If there is no way to replace all the question marks with uppercase letters such that the resulting word is nice, then print  - 1 in the only line.

Otherwise, print a string which denotes a possible nice word that ZS the Coder learned. This string should match the string from the input, except for the question marks replaced with uppercase English letters.

If there are multiple solutions, you may print any of them.

Example

Input
ABC??FGHIJK???OPQR?TUVWXY?
Output
ABCDEFGHIJKLMNOPQRZTUVWXYS
Input
WELCOMETOCODEFORCESROUNDTHREEHUNDREDANDSEVENTYTWO
Output
-1
Input
??????????????????????????
Output
MNBVCXZLKJHGFDSAQPWOEIRUYT
Input
AABCDEFGHIJKLMNOPQRSTUVW??M
Output
-1

Note

In the first sample case, ABCDEFGHIJKLMNOPQRZTUVWXYS is a valid answer beacuse it contains a substring of length 26 (the whole string in this case) which contains all the letters of the English alphabet exactly once. Note that there are many possible solutions, such as ABCDEFGHIJKLMNOPQRSTUVWXYZ or ABCEDFGHIJKLMNOPQRZTUVWXYS.

In the second sample case, there are no missing letters. In addition, the given string does not have a substring of length 26 that contains all the letters of the alphabet, so the answer is  - 1.

In the third sample case, any string of length 26 that contains all letters of the English alphabet fits as an answer.

找出字符串的一个子串,所有字母只出现一遍,且26个字母齐全,或者补缺?位能得到26个字母排列的子串,则输出填补后的字符串,否则输出-1。用一个数组来标记,记录字母出现的位置,如果一个字母出现了两遍,那么就回到他出现第一次位置的下一位,所有的数据初始化,继续寻找,直到符合要求了跳出循环。

代码:

#include <iostream>
#include <map>
#include <algorithm>
#include <cstring>
using namespace std;
int main()
{
string a;
int t = ;
int c = ;
int check[] = {};
cin>>a;
int n = ;
for(int i = ;i < a.size();i ++)
{
if(n + c >= )break;
if(a[i] == '?')n ++;
else if(a[i] >= 'A' && a[i] <= 'Z')
{
if(!check[a[i] - 'A'])
{
check[a[i] - 'A'] = i + ;
c ++;
}
else
{
i = check[a[i] - 'A'] - ;
t = i + ;
n = c = ;
memset(check,,sizeof(check));
}
}
}
if(n + c < )cout<<-<<endl;
else
{
int j = ;
for(int i = ;i < a.size();i ++)
{
if(a[i] != '?')cout<<a[i];
else if(i >= t && i <= t + )
{
while(check[j])j++;
cout<<(char)('A'+j);
j ++;
}
else cout<<'A';//无关紧要的可以随意填补,只要保证满足要求的子串填补好了,其他的随便填补,子串一定要是连续的26个
}
}
}

Complete the Word的更多相关文章

  1. Codeforces 716B Complete the Word【模拟】 (Codeforces Round #372 (Div. 2))

    B. Complete the Word time limit per test 2 seconds memory limit per test 256 megabytes input standar ...

  2. B. Complete the Word(Codeforces Round #372 (Div. 2)) 尺取大法

    B. Complete the Word time limit per test 2 seconds memory limit per test 256 megabytes input standar ...

  3. Codeforces Round #372 (Div. 2) A .Crazy Computer/B. Complete the Word

    Codeforces Round #372 (Div. 2) 不知不觉自己怎么变的这么水了,几百年前做A.B的水平,现在依旧停留在A.B水平.甚至B题还不会做.难道是带着一种功利性的态度患得患失?总共 ...

  4. codeforces 372 Complete the Word(双指针)

    codeforces 372 Complete the Word(双指针) 题链 题意:给出一个字符串,其中'?'代表这个字符是可变的,要求一个连续的26位长的串,其中每个字母都只出现一次 #incl ...

  5. Complete the Word CodeForces - 716B

    ZS the Coder loves to read the dictionary. He thinks that a word is nice if there exists asubstring  ...

  6. CodeForces 716B Complete the Word

    题目链接:http://codeforces.com/problemset/problem/716/B 题目大意: 给出一个字符串,判断其是否存在一个子串(满足:包含26个英文字母且不重复,字串中有‘ ...

  7. Mou常用快捷键

    title: Mou常用快捷键date: 2015-11-08 17:16:38categories: 编辑工具 tags: mou 小小程序猿我的博客:http://daycoding.com Vi ...

  8. Codeforces Round #370 - #379 (Div. 2)

    题意: 思路: Codeforces Round #370(Solved: 4 out of 5) A - Memory and Crow 题意:有一个序列,然后对每一个进行ai = bi - bi  ...

  9. Codeforces水题集合[14/未完待续]

    Codeforces Round #371 (Div. 2) A. Meeting of Old Friends |B. Filya and Homework A. Meeting of Old Fr ...

随机推荐

  1. Linux下Tomcat启动设置debug模式启动

    原文: https://blog.csdn.net/li295214001/article/details/42077247 https://blog.csdn.net/jackie_xiaonan/ ...

  2. C#代码安装、卸载、监控Windows服务

    C#编写Windows服务之后都不可避免的需要安装,卸载等操作.而传统的方式就是通过DOS界面去编写命令,这样的操作方式无疑会增加软件实施人员的工作量,下面就介绍一种简单.高效.快速方便的方式.1.安 ...

  3. R语言plot函数参数合集

    最近用R语言画图,plot 函数是用的最多的函数,而他的参数非常繁多,由此总结一下,以供后续方便查阅. plot(x, y = NULL, type = "p", xlim = N ...

  4. C#退出模式

    1.this.Close();   只是关闭当前窗口,若不是主窗体的话,是无法退出程序的,另外若有托管线程(非主线程),也无法干净地退出: 2.Application.Exit();  强制所有消息中 ...

  5. 20170716xlVba销售明细转销售单据

    Sub CreateSaleList() AppSettings On Error GoTo ErrHandler Dim StartTime As Variant '开始时间 Dim UsedTim ...

  6. codeforces 521a//DNA Alignment// Codeforces Round #295(Div. 1)

    题意:如题定义的函数,取最大值的数量有多少? 结论只猜对了一半. 首先,如果只有一个元素结果肯定是1.否则.s串中元素数量分别记为a,t,c,g.设另一个串t中数量为a',t',c',g'.那么,固定 ...

  7. Oracle11g温习-第五章:数据字典

    1.数据字典(Data dictionary)的功能 1)   central of oracle   database               每个oracle数据库的核心 2)   descr ...

  8. Razor视图引擎 语法学习

    下面就和大家分享下我在asp.net官网看到的资料,学习到的点语法.1.通过使用@符号,可以直接在html页面中写C#或者VB代码:运行后: 2.页面中的C#或者VB代码都放在大括号中.运行后: 3. ...

  9. 5.4 使用 Razor 表达式

    以下内容主要展示 Razor 所支持的各种表达式,以及如何用它们来创建视图的内容. 在一个好的 MVC 框架应用程序中,动作方法与视图的作用是清晰.分离的.其规则很简单,如表所示: 组件 要做的事 不 ...

  10. 小议常被忽略的a标签:visited属性的特殊用法

    CSS1/CSS2对于a定义了4个伪类, :link  a标签未访问时的样式 :active  a标签mousedown时的样式 :hover  a标签mouseover时的样式 :visited  ...