比赛的时候还特别撒比地写了二分的那个写法,然后wa了一发,因为这个集合的翻译成自然数集。还是转换了一下,还是去写了一个二分。

后面就是出现几种就是多长。。。

比赛的真的非常非常挫的code….

#include<iostream>
#include<cstdio>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<math.h>
#include<string.h>
#include<algorithm>
using namespace std;
#define eps 1e-8
typedef __int64 LL; const int N=1e5+10; int d[N];
int a[N];
char s[N];
int vis[1000];
int n; int kill(int len,int x)
{
int b=1,e=len;
while(b<=e)
{
int mid=(b+e)/2;
if(x>d[mid])
b=mid+1;
else
e=mid-1;
}
return b;
} void Init()
{
memset(vis,0,sizeof(vis));
int cnt=1;
for(int i=1;i<=n;i++)
{
int x=s[i];
if(!vis[x])
vis[x]=cnt++;
}
} int main()
{
int t;
int cas=1;
scanf("%d",&t);
while(t--)
{
scanf("%s",s+1);
n=strlen(s+1); Init(); for(int i=1;i<=n;i++)
{
int x=s[i];
a[i]=vis[x];
}
d[1]=a[1];
int len=1;
int j;
for(int i=2;i<=n;i++)
{
if(d[1]>=a[i]) //如果比最小的还小
j=1;
else if(a[i]>d[len]) //如果比最大的还大
{
j=++len;
}
else
{
j=kill(len,a[i]);
}
d[j]=a[i];
}
printf("Case #%d: %d\n",cas++,len);
}
return 0;
}

hdoj5842【水题】的更多相关文章

  1. HDOJ 2317. Nasty Hacks 模拟水题

    Nasty Hacks Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Tota ...

  2. ACM :漫漫上学路 -DP -水题

    CSU 1772 漫漫上学路 Time Limit: 1000MS   Memory Limit: 131072KB   64bit IO Format: %lld & %llu Submit ...

  3. ytu 1050:写一个函数,使给定的一个二维数组(3×3)转置,即行列互换(水题)

    1050: 写一个函数,使给定的一个二维数组(3×3)转置,即行列互换 Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 154  Solved: 112[ ...

  4. [poj2247] Humble Numbers (DP水题)

    DP 水题 Description A number whose only prime factors are 2,3,5 or 7 is called a humble number. The se ...

  5. gdutcode 1195: 相信我这是水题 GDUT中有个风云人物pigofzhou,是冰点奇迹队的主代码手,

    1195: 相信我这是水题 Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 821  Solved: 219 Description GDUT中有个风云人 ...

  6. BZOJ 1303 CQOI2009 中位数图 水题

    1303: [CQOI2009]中位数图 Time Limit: 1 Sec  Memory Limit: 162 MBSubmit: 2340  Solved: 1464[Submit][Statu ...

  7. 第十一届“蓝狐网络杯”湖南省大学生计算机程序设计竞赛 B - 大还是小? 字符串水题

    B - 大还是小? Time Limit:5000MS     Memory Limit:65535KB     64bit IO Format: Description 输入两个实数,判断第一个数大 ...

  8. ACM水题

    ACM小白...非常费劲儿的学习中,我觉得目前我能做出来的都可以划分在水题的范围中...不断做,不断总结,随时更新 POJ: 1004 Financial Management 求平均值 杭电OJ: ...

  9. CF451C Predict Outcome of the Game 水题

    Codeforces Round #258 (Div. 2) Predict Outcome of the Game C. Predict Outcome of the Game time limit ...

  10. CF451B Sort the Array 水题

    Codeforces Round #258 (Div. 2) Sort the Array B. Sort the Array time limit per test 1 second memory ...

随机推荐

  1. 用CSS美化你的HTML

    CSS的简介: 1.CSS的定义:层叠样式表.属性和属性值用冒号分隔开,以分号结尾(这些符号都是英文的). 2.CSS得引入方式: 行内引入:<div style="这里写样式&quo ...

  2. EF使用自定义字符串连接数据库

    edmx的构造函数: public TestCheckUpdatesEntities(): base(Config.DataBaseConnectionString(), "TestChec ...

  3. Linux环境下如何查找哪个线程使用CPU最长

    top -H -p pid 查看端口是否被占用: netstat -apn|grep 80

  4. window批处理-5 start

    作用 又一次启动一个单独窗体.在新窗体中运行命令 格式 start [/w] FileName demo bat: @echo off echo 在新窗体中打开txt文件.并等待新窗体正常退出(exi ...

  5. Python开发【2.1 面向对象】

    1.面向对象概述 类(Class): 用来描述具有相同的属性和方法的对象的集合.它定义了该集合中每个对象所共有的属性和方法.对象是类的实例. 类变量:类变量在整个实例化的对象中是公用的.类变量定义在类 ...

  6. MVC Controller构造器注入

    UnityDependencyResolver 的标准写法 public class UnityDependencyResolver : IDependencyResolver {     priva ...

  7. JavaScript重点记忆

    String的常用方法 indexOf() 返回字符串中检索指定字符第一次出现的位置 lastIndexOf() 返回字符串中检索指定字符最后一次出现的位置 match() 找到一个或多个正则表达式的 ...

  8. 将异常(getStackTrace)转化成String

    方法一: private static String getStackMsg(Exception e) { StringBuffer sb = new StringBuffer(); StackTra ...

  9. p1697食物链

    动物王国中有三类动物A,B,C,这三类动物的食物链构成了有趣的环形.A吃B, B吃C,C吃A.现有N个动物,以1-N编号.每个动物都是A,B,C中的一种,但是我们并不知道它到底是哪一种.有人用两种说法 ...

  10. RK3288 GPIO 输出问题【转】

    本文转载自:http://m.blog.csdn.net/jiangdou88/article/details/50158673 #define GPIO_BANK0              (0 ...