CF716B Complete the Word

题意翻译

给你六个单词,要求拼成一个字典序最小的字符8字形,空的地方用.代替。

题目描述

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 2626 where each letter of English alphabet appears exactly once. In particular, if the string has length strictly less than 2626 , 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?

输入输出格式

输入格式:

The first and only line of the input contains a single string ss ( 1<=|s|<=500001<=∣s∣<=50000 ), 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.

输出格式:

If there is no way to replace all the question marks with uppercase letters such that the resulting word is nice, then print -1−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.

输入输出样例

输入样例#1: 复制

ABC??FGHIJK???OPQR?TUVWXY?

输出样例#1: 复制

ABCDEFGHIJKLMNOPQRZTUVWXYS

输入样例#2: 复制

WELCOMETOCODEFORCESROUNDTHREEHUNDREDANDSEVENTYTWO

输出样例#2: 复制

-1

输入样例#3: 复制

??????????????????????????

输出样例#3: 复制

MNBVCXZLKJHGFDSAQPWOEIRUYT

输入样例#4: 复制

AABCDEFGHIJKLMNOPQRSTUVW??M

输出样例#4: 复制

-1

// 暴力。错了很多次,无话可说。
// 字符串中的所有问号都要变,,,,,,#include<iostream>
#include<queue>
#include<cstring>
using namespace std;
char str[50009];
int main(void){while( scanf("%s",str)!=EOF){int len = strlen( str );if( len < 26 ){printf("-1\n");continue;}else {int vis[30];int cnt = 0 , id ,flag = 0;memset(vis,0,sizeof(vis));for( int i=0;i<len;i++){cnt++;id = str[i] - 'A'; if( str[i] != '?' ){if( vis[id] == 0  ){ vis[id] = 1;    }else {i =  i - cnt +1;cnt =0;memset(vis,0,sizeof(vis));}}if( cnt == 26 ){queue<char> q;for( int k = 0;k<=25;k++ ){if(!vis[k]){q.push( 'A'+k);}} for( int j=i;j>=i-25;j--){if( str[j] =='?'){str[j] = q.front();q.pop();      } }for( int l =0;l<len;l++){if(str[l] == '?')str[l] = 'A';} printf("%s\n",str);flag = 1;break; }     } if( !flag ){printf("-1\n");}}}return 0;
}

CF716B Complete the Word相关推荐

  1. Codeforces Round #372 (Div. 2), problem: (B) Complete the Word

    水题,每次截取长度为26的字符串,然后直接进行修改就可以 然而本弱渣昨天wa看很久 include<bits/stdc++.h> using namespace std; int n,c; ...

  2. 【Codeforces】716B Complete the Word (26个字母)

    http://codeforces.com/contest/716/problem/B 给你一个字符串该字符串中是否存在长度为26且这26个字母没有重复 一个满足上述条件但是部分区域是问号的话,需要用 ...

  3. B. Complete the Word (尺取法)

    题目链接:http://codeforces.com/problemset/problem/716/B 题目大意:字符串中的 '?' 可以用A->Z任何一个来替换 问能不能通过替换使字符串有一个 ...

  4. Trie(前缀树/字典树)及其应用

    from:https://www.cnblogs.com/justinh/p/7716421.html Trie,又经常叫前缀树,字典树等等.它有很多变种,如后缀树,Radix Tree/Trie,P ...

  5. Trie树(字典树)详细知识点及其应用

    Trie,又经常叫前缀树,字典树等等.它有很多变种,如后缀树,Radix Tree/Trie,PATRICIA tree,以及bitwise版本的crit-bit tree.当然很多名字的意义其实有交 ...

  6. What's New in C# 6.0(转)

    原文地址:http://www.codeproject.com/Tips/1023426/Whats-New-in-Csharp 本来想翻译一下贴出来,但是好像很多语言组织起来比较困难,读书少不会表达 ...

  7. [转] Mou 一个Markdown工具 语法规则文档(最后)

    原文地址:http://blog.csdn.net/coolwxb/article/details/50803602 View 显示预览窗口 Toggle live preview: Shift + ...

  8. 2018SDIBT_国庆个人第七场

    A - Complete the Word(暴力) Description ZS the Coder loves to read the dictionary. He thinks that a wo ...

  9. element ui字段_ui备忘单下拉字段

    element ui字段 重点 (Top highlight) Dropdowns get a lot of flak from the UI world – and if we are honest ...

最新文章

  1. python 中遍历表时候,当指定的表的长度超过实际长度时候,实际遍历的长度以表实际长度为准,不会发生越界,如下
  2. python流程控制语句-python语言的流程控制
  3. nginx日志分析查询异常请求IP之狙击网络黑客
  4. flash开发中如何实现界面代码分离
  5. 需求评审五个维度框架分析及其带来的启示-总起
  6. ASP.NET三层架构之不确定查询参数个数的查询
  7. Scala的存在类型
  8. Linux下DIR,dirent,stat等结构体详解
  9. 【数学建模】 插值算法
  10. 一个女生最好的生活状态
  11. 逆势马丁网格策略交易演示
  12. 数字视频的发展从1080i到720p再到1080p
  13. 【华为2019届校园招聘】算法工程师面试总结
  14. Quantopian 入门系列二 - 流水线 (上)
  15. 用IntelliJ IDEA开发Python
  16. PMO如何有效搭建项目管理体系︱伯俊软件PMO经理李双燕
  17. NVIDIA AGX xavier 系列一 刷机步骤经验总结
  18. Win10改用microsoft账户登录发生了错误怎么解决?
  19. FlaskWeb开发从入门到放弃(二)
  20. 1.Excel vba开发-处理空格数据

热门文章

  1. 怎样了解某领域的研究进展与发展趋势
  2. softboy安卓软件
  3. Mac wifi 密码更改
  4. 购买全光谱照明灯真的护眼吗?推荐五款护眼台灯
  5. TTylinux 最小的系统(带GCC)
  6. ubentu 16下samba共享文件夹配置
  7. 《从Paxos到Zookeeper 分布式一致性原理与实践》
  8. c语言编程main,C语言main()函数
  9. 文兴小学安全工作自查报告
  10. 《机器学习实战》 Logistic回归预测患有疝气病的马的存活问题