LIS的string用法
使用的是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用法的更多相关文章
- c++ std::string 用法
std::string用法总结 在平常工作中经常用到了string类,本人记忆了不好用到了的时候经常要去查询.在网上摘抄一下总结一下,为以后的查询方便: string类的构造函数: string(co ...
- String... 用法
今天看到一个没见过的函数参数列表test(int... a),查看资料,原来是如下用法:类型后面三个点(String...),是从Java 5开始,Java语言对方法参数支持一种新写法,叫可变长度参数 ...
- C++ string 用法详解
/////////////////////////////////////////////////////////////////////////////////// 任何人对本文进行引用都要标明作者 ...
- std::string 用法总结
标准C++中的string类的用法总结 相信使用过MFC编程的朋友对CString这个类的印象应该非常深刻吧?的确,MFC中的CString类使用起来真的非常的方便好用.但是如果离开了MFC框架,还有 ...
- std::string 用法
string类的构造函数:string(const char *s); //用c字符串s初始化string(int n,char c); //用n个字符c初始化 string类的字符操作:const ...
- python的string用法
s.strip().lstrip().rstrip(',') S.lower() #小写 S.upper() #大写 S.swapcase() #大小写互换 S.capitalize() #首字母大写 ...
- string用法
截取字符串 string strTributeInfo = "1#2#3#4#5#6#7"; vector<string> vecTribute; StringUtil ...
- c++ string用法
首先,为了在我们的程序中使用string类型,我们必须包含头文件 .如下: #include //注意这里不是string.h string.h是C字符串头文件 1.声明一个C++字符串 声明一个字 ...
- iOS开发宝典:String用法大全
一.NSString 创建字符串. NSString *astring = @"This is a String!"; 创建空字符串,给予赋值. NSString *astri ...
随机推荐
- 转 sql profile 绑定 litera and move profile to another db l for spa
SQL TYPE 1:for bind value sql , first create a good plan with literal and with good profile. then u ...
- c语言字符函数
函数名: stpcpy 功 能: 拷贝一个字符串到另一个 用 法: char *stpcpy(char *destin, char *source); 程序例: #include <stdi ...
- (转)shell实例浅谈之产生随机数七种方法
一.问题 Shell下有时需要使用随机数,在此总结产生随机数的方法.计算机产生的的只是“伪随机数”,不会产生绝对的随机数(是一种理想随机数).伪随机数在大量重现时也并不一定保持唯一,但一个好的伪随机产 ...
- 设置webstorm的file watch 监视scss文件
参考:http://blog.founddrama.net/2013/04/watching-compass-files-in-webstorm/ 上面红色划线部分. 特别注意arguments: 像 ...
- php防止重复提交问题总结
用户提交表单时可能因为网速的原因,或者网页被恶意刷新,致使同一条记录重复插入到数据库中,这是一个比较棘手的问题.我们可以从客户端和服务器端一起着手,设法避免同一表单的重复提交. 1.使用客户端脚本 提 ...
- Apache-ant安装以及环境变量配置、验证
(一)安装 ant 下载地址: http://ant.apache.org/ 根据自己电脑下载对应版本 下载完成以后,可自行解压到自己常用的盘中,但是要记住解压到哪里了,以便后续的环境变量配置 ...
- REST API 自动化测试 利器Rest Assured(API接口自动化测试框架体系)
现在,越来越多的 Web 应用转向了 RESTful 的架构,很多产品和应用暴露给用户的往往就是一组 REST API,这样有一个好处,用户可以根据需要,调用不同的 API,整合出自己的应用出来.从这 ...
- 微信小程序获取数据、处理数据、绑定数据关键步骤记录
onload:function(event){ var inTheatersUrl ="https://api.douban.com"+"/v2/movie/in_the ...
- linq to entity 左连接 右连接 以及内连接写法的区别
左连右连还是内连这个其实你不需要关心.只需要根据实体的映射关系写查询,框架会自动帮你生成的. 至于linq查询语法与扩展方法的效率,应该是一样的,比如: var users=(from u in db ...
- Mysql 求时间 between 昨天 and 上个月的今天 等时间函数
问题: Mysql表中一列create_time,类型datetime(YYYY-MM-DD HH:MM:SS),想获取上个月今天到昨天的数据. select * from 表名 where date ...