比赛的时候还特别撒比地写了二分的那个写法,然后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. selenium python (九)对话框处理

    #!/usr/bin/python# -*- coding: utf-8 -*-__author__ = 'zuoanvip' from selenium import  webdriver #对于对 ...

  2. weex 阶段总结

    新年伊始,回顾过去的一年,收获很多,之前一直在研究weex,说心里话感觉心好累,官方文档不全,社区不活跃,遇到很多坑,官方发布的版本有时都有坑,搞得我都不敢更新版本了. 但是,研究了这么久,放弃太可惜 ...

  3. POJ3420 Quad Tiling DP + 矩阵高速幂

    题目大意是用1*2的骨牌堆积成4*N的矩形.一共同拥有多少种方法,N不超过10^9. 这题和以前在庞果网上做过的一道木块砌墙差点儿一样. 由于骨牌我们能够横着放.竖着放.我们如果以4为列,N为行这样去 ...

  4. WebService CXF Spring

    web.xml <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi=" ...

  5. MVC框架的优缺点

    MVC框架的优缺点 解析:M(Model)-模型,V(View)-视图.C(Controller)-控制器 作用:M-处理应用程序数据部分,V-处理数据展示的部分.C-处理用户交互,逻辑功能实现 1. ...

  6. firefox浏览器和IE

    http://blog.csdn.net/pipisorry/article/details/40899701 firefox浏览器插件 [下载地址add-ons for firefox]皮皮blog ...

  7. 按行读入xml文件,删除不需要的行 -Java

    删除挺麻烦的,这里其实只是把需要的行存到arraylist中再存到另一个文件中 import java.io.BufferedReader;import java.io.BufferedWriter; ...

  8. Android 的assets文件资源与raw文件资源读取

    版权声明:本文为博主原创文章,未经博主同意不得转载. https://blog.csdn.net/zpf8861/article/details/34504183   res/raw和assets的同 ...

  9. (28)java web的hibernate使用

    Hibernate是一个开放源代码的对象关系映射框架,它对JDBC进行了非常轻量级的对象封装,它将POJO与数据库表建立映射关系,是一个全自动的orm框架,hibernate可以自动生成SQL语句,自 ...

  10. filename extension

    题目描述 Please create a function to extract the filename extension from the given path,return the extra ...