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 ...
随机推荐
- gitlab 的安装、汉化、卸载
新机 dell服务器 2核4G 官网: https://about.gitlab.com/install/ 1.本次安装选择版本v10.8.4 wget https://mirrors.tuna.ts ...
- SQL---MySQL数据库---聚合函数
1.数值 format(x,n) 将x格式化为 由逗号分隔,小数点后n 位的数:
- Hive学习(一)
https://www.cnblogs.com/qingyunzong/p/8707885.html http://www.360doc.com/content/16/1006/23/15257968 ...
- 2019.03.22 读书笔记 var object dynamic
var:语法糖,在编译时推断出类型,根据反编译可以看出.实际用处是增加代码的健壮性,比如 linq ,匿名对象等. object:很多人容易和var混淆,其实概念上完全不同,没什么可比性. dynam ...
- LISP语言学习资源
LISP的介绍:Paul Graham 的主页 http://paulgraham.com/index.html Lisp之根源 - 保罗·格雷厄姆 http://daiyuwen.freeshell ...
- 性能测试工具LoadRunner18-LR之Controller 集合点
含义 当通过controller虚拟多个用户执行该脚本时.用户的启动或运行步骤不一定是同步的.集合点是在脚本的某处设置一个标记.当有虚拟用户运行到这个标记时,停下等待,直到所有用户都达到这个标记时,再 ...
- 【转】Android Canvas绘图详解
转自:http://www.jcodecraeer.com/a/anzhuokaifa/androidkaifa/2012/1212/703.html Android中使用图形处理引擎,2D部分是an ...
- EF删除数据
1.方法一,面向对象 using (MyDbContent content = new MyDbContent()) { content.Entry<UserInfo>(model).St ...
- 阿里云短信验证~JAVA后台
maven :中的 pom.xml添加 <dependency> <groupId>com.aliyun</groupId> <artifactId>a ...
- Net-SNMP(V3协议)安装配置笔记(CentOS 5.2)(转)
原出处:http://blog.ihipop.info/2010/03/722.html 为了这颗仙人掌(cacti),我必须先部署(Net-SNMP), 同时我为了安全因素,也为了简便考虑,决定采用 ...