思路:

尺取,写挫了,debug了半天。

#include <bits/stdc++.h>
using namespace std; typedef long long LL; const int N=1e5+10; char ch[N];
int vis[1001]; int main()
{
int s,t;
scanf("%s",ch);
memset(vis,0,sizeof(vis));
int len=strlen(ch);
int num=0;
int ans=len+1;
for(s=0,t=-1;s<len&&t<len;)
{
while(num<26&&t<len)//结果是s-t为满足串,t为正好满足的结尾。
{
t++;
if(ch[t]>='A'&&ch[t]<='Z')
{
if(!vis[ch[t]-'A'])
num++;
vis[ch[t]-'A']++;
}
if(num==26)
{
ans=min(ans,t-s+1);
break;
}
}
while(num==26&&s<len)//结果为s-t刚好是不满足的,注意s位置是要不满足的起始
{
if(ch[s]>='A'&&ch[s]<='Z')
{
if(vis[ch[s]-'A']==1)
num--;
vis[ch[s]-'A']--;
}
if(num==26)
{
ans=min(ans,t-s);
}
s++;
}
}
if(ans==len+1)
puts("No Solution");
else
printf("%d\n",ans);
return 0;
}

51nod1127【尺取】的更多相关文章

  1. Gym 100703I---Endeavor for perfection(尺取)

    题目链接 http://codeforces.com/problemset/gymProblem/100703/I Description standard input/outputStatement ...

  2. NOJ 1072 The longest same color grid(尺取)

    Problem 1072: The longest same color grid Time Limits:  1000 MS   Memory Limits:  65536 KB 64-bit in ...

  3. hdu 4123 Bob’s Race 树的直径+rmq+尺取

    Bob’s Race Time Limit: 5000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Probl ...

  4. Codeforces Round #116 (Div. 2, ACM-ICPC Rules) E. Cubes (尺取)

    题目链接:http://codeforces.com/problemset/problem/180/E 给你n个数,每个数代表一种颜色,给你1到m的m种颜色.最多可以删k个数,问你最长连续相同颜色的序 ...

  5. poj2566尺取变形

    Signals of most probably extra-terrestrial origin have been received and digitalized by The Aeronaut ...

  6. poj2100还是尺取

    King George has recently decided that he would like to have a new design for the royal graveyard. Th ...

  7. hdu 6231 -- K-th Number(二分+尺取)

    题目链接 Problem Description Alice are given an array A[1..N] with N numbers. Now Alice want to build an ...

  8. Codeforces 939E Maximize! (三分 || 尺取)

    <题目链接> 题目大意:给定一段序列,每次进行两次操作,输入1 x代表插入x元素(x元素一定大于等于之前的所有元素),或者输入2,表示输出这个序列的任意子集$s$,使得$max(s)-me ...

  9. cf1121d 尺取

    尺取,写起来有点麻烦 枚举左端点,然后找到右端点,,使得区间[l,r]里各种颜色花朵的数量满足b数组中各种花朵的数量,然后再judge区间[l,r]截取出后能否可以供剩下的n-1个人做花环 /* 给定 ...

随机推荐

  1. Effective C++ 条款17 以独立语句将newed对象置入智能指针

      对于函数: int priority(); void processWidget(std::tr1::  shared_ptr<Widget> pw,int priority); 调用 ...

  2. yii第三方插件snoopy配置

    首先.把snoopy类放到protected\extensions\snoopy\目录下. 其次.在yii配置文件main.php里配置import扩展进来. 'import'=>array( ...

  3. linux 输入子系统(2) platform device

      Input  platform  device 一般是在板级bsp注册了的资源. 以gpio-keys为例: #####################gpio_key.h############ ...

  4. 项目Beta冲刺(团队4/7)

    项目Beta冲刺(团队4/7) 团队名称: 云打印 作业要求: 项目Beta冲刺(团队) 作业目标: 完成项目Beta版本 团队队员 队员学号 队员姓名 个人博客地址 备注 221600412 陈宇 ...

  5. SSM整理笔记1——SSM网站初步功能设计

    前言 因为公司里一直用Hibernate,但是现在Mybatis是趋势,所以搭建一个Mybatis的网站框架,目的是:1摸清其功能特点,2为以后的项目增加框架选择(以前只用hibernate或者Spr ...

  6. Mahout 0.5部署

    Mahout下载与安装 1.下载Mahout.到地址[1]可以找到镜像地址.我们下载Mahout 0.5.请将mahout-distribution-0.5.tar.gz和mahout-distrib ...

  7. Comparing Random and Sequential Access in Disk and Memory

    The Pathologies of Big Data - ACM Queue https://queue.acm.org/detail.cfm?id=1563874

  8. ElasticSearch远程随意代码运行漏洞(CVE-2014-3120)分析

    原理 这个漏洞实际上非常easy,ElasticSearch有脚本运行(scripting)的功能,能够非常方便地对查询出来的数据再加工处理. ElasticSearch用的脚本引擎是MVEL,这个引 ...

  9. html 常用转译空格字符

    本人有时候做表格强迫症,字段有的是3个字有的是4个字,也有两个字的,所有不对齐感觉看着难受, 因此需要用空格来让表头文字对齐,找到了下面几个常用的转译字符. 1.  &160#;不断行的空白( ...

  10. table 中的thead tbody

    通过thead 下的tr 设置样式以及 tbody 下的 tr 设置样式 避免冲突 <table> <thead> <tr> <td> </td& ...