题目链接

使用的是string里的find函数

stl大法好

#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
string in;
string f[10000];
int mf=1;
void insert(int begin,int end,string value)
{
int l=begin,r=end;
while(l<r)
{
int mid=(l+r)/2;
bool flag=value.find(f[mid]);
if(flag)
r=mid;
if(!flag)
l=mid+1;
}
f[l]=value;
if(l==mf)
mf++;
}
int main()
{
int n;
scanf("%d",&n);
for(int i=1;i<=n;i++)
f[i]="";
for(int i=1;i<=n;i++)
{
cin>>in;
insert(1,mf,in);
}
printf("%d",mf-1);
}

还有洛谷用户da32s1da大佬整理的find等一类函数的用法

//string类的查找函数:

int find(char c, int pos = 0) const;//从pos开始查找字符c在当前字符串的位置
int find(const char *s, int pos = 0) const;//从pos开始查找字符串s在当前串中的位置
int find(const char *s, int pos, int n) const;//从pos开始查找字符串s中前n个字符在当前串中的位置
int find(const string &s, int pos = 0) const;//从pos开始查找字符串s在当前串中的位置
//查找成功时返回所在位置,失败返回string::npos的值 int rfind(char c, int pos = npos) const;//从pos开始从后向前查找字符c在当前串中的位置
int rfind(const char *s, int pos = npos) const;
int rfind(const char *s, int pos, int n = npos) const;
int rfind(const string &s,int pos = npos) const;
//从pos开始从后向前查找字符串s中前n个字符组成的字符串在当前串中的位置,成功返回所在位置,失败时返回string::npos的值 int find_first_of(char c, int pos = 0) const;//从pos开始查找字符c第一次出现的位置
int find_first_of(const char *s, int pos = 0) const;
int find_first_of(const char *s, int pos, int n) const;
int find_first_of(const string &s,int pos = 0) const;
//从pos开始查找当前串中第一个在s的前n个字符组成的数组里的字符的位置。查找失败返回string::npos int find_first_not_of(char c, int pos = 0) const;
int find_first_not_of(const char *s, int pos = 0) const;
int find_first_not_of(const char *s, int pos,int n) const;
int find_first_not_of(const string &s,int pos = 0) const;
//从当前串中查找第一个不在串s中的字符出现的位置,失败返回string::npos int find_last_of(char c, int pos = npos) const;
int find_last_of(const char *s, int pos = npos) const;
int find_last_of(const char *s, int pos, int n = npos) const;
int find_last_of(const string &s,int pos = npos) const; int find_last_not_of(char c, int pos = npos) const;
int find_last_not_of(const char *s, int pos = npos) const;
int find_last_not_of(const char *s, int pos, int n) const;
int find_last_not_of(const string &s,int pos = npos) const;
//find_last_of和find_last_not_of与find_first_of和find_first_not_of相似,只不过是从后向前查找

链接

LIS的string用法的更多相关文章

  1. c++ std::string 用法

    std::string用法总结 在平常工作中经常用到了string类,本人记忆了不好用到了的时候经常要去查询.在网上摘抄一下总结一下,为以后的查询方便: string类的构造函数: string(co ...

  2. String... 用法

    今天看到一个没见过的函数参数列表test(int... a),查看资料,原来是如下用法:类型后面三个点(String...),是从Java 5开始,Java语言对方法参数支持一种新写法,叫可变长度参数 ...

  3. C++ string 用法详解

    /////////////////////////////////////////////////////////////////////////////////// 任何人对本文进行引用都要标明作者 ...

  4. std::string 用法总结

    标准C++中的string类的用法总结 相信使用过MFC编程的朋友对CString这个类的印象应该非常深刻吧?的确,MFC中的CString类使用起来真的非常的方便好用.但是如果离开了MFC框架,还有 ...

  5. std::string 用法

    string类的构造函数:string(const char *s); //用c字符串s初始化string(int n,char c); //用n个字符c初始化 string类的字符操作:const ...

  6. python的string用法

    s.strip().lstrip().rstrip(',') S.lower() #小写 S.upper() #大写 S.swapcase() #大小写互换 S.capitalize() #首字母大写 ...

  7. string用法

    截取字符串 string strTributeInfo = "1#2#3#4#5#6#7"; vector<string> vecTribute; StringUtil ...

  8. c++ string用法

    首先,为了在我们的程序中使用string类型,我们必须包含头文件 .如下: #include  //注意这里不是string.h string.h是C字符串头文件 1.声明一个C++字符串 声明一个字 ...

  9. iOS开发宝典:String用法大全

    一.NSString 创建字符串.  NSString *astring = @"This is a String!"; 创建空字符串,给予赋值.  NSString *astri ...

随机推荐

  1. 跨域的问题(jsonp和cors)

    由于浏览器的同源策略,用户想要跨域访问浏览器就会报错,那么就涉及到解决跨域的问题.最近我接触到的解决方法是两个,jsonp和cors. jsonp(json with padding)我们虽然不能直接 ...

  2. JVM发展史和Java运行时内存区域

    目前三大主流JVM: Sun HotSpot:Sun于1997年收购Longview Technologies公司所得.Sun于2009年被Oracle收购. BEA JRockit:BEA于2002 ...

  3. shell 0学习

    例一:列出/home 文件夹下的所有文件和目录的详细资料,可以使用如下命令:  ls -a -l /home   ls -al /home 例二:列出当前目录中所有以”d”开头的文件目录的详细内容,可 ...

  4. [转]jQueryUI中Datepicker(日历)插件的介绍和使用

    http://jqueryui.com/datepicker/ 本文转自:http://blog.csdn.net/redarmy_chen/article/details/7400571 jQuer ...

  5. Java方法-对指定信息基于相关维度进行分组

    近期项目中需要针对多种不同来源指定的相同类型内容进行合并,实现过程中需要根据指定的相关维度,对资源内容进行分组,如识别是否可以为同一人员信息,是否为同一个歌曲或影视信息,因此针对实现的具体细节做如下备 ...

  6. HDU 4336——Card Collector——————【概率dp】

    Card Collector Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)To ...

  7. D5上

    好慌啊 0分?? T1 感觉是组合数,不知道对不对. #include<iostream> #include<cstring> #include<cstdio> # ...

  8. MVC学习手册之数据注解与验证

    MVC学习手册之数据注解与验证 新建一个MVC5的WEB应用程序,VS2013会自动生成一段代码,以下是Account控制器下Register.cshtml 页面的代码: @model WebAppl ...

  9. [转]开发中如何解决SQL注入的问题

    Java防止SQL注入 SQL 注入简介:        SQL注入是最常见的攻击方式之一,它不是利用操作系统或其它系统的漏洞来实现攻击的,而是程序员因为没有做好判断,被不法用户钻了SQL的空子,下面 ...

  10. JS判断web网站访问端是PC电脑还是手机

    通过JS语句判断WEB网站的访问端是电脑还是手机,以显示不同的页面! <script type="text/javascript"> <!-- //平台.设备和操 ...