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 ...
随机推荐
- 1.Exadata技术演进
V1-v2 和 HP Exadata 2-2 和 SUN 2011 3-2 4-2 5-2 2014底 2-2 混合运算 2-8 是大数据运算 问题1. 随着系统规模增加,传统数据库架 ...
- Robot Framework常用库简介
标准库 Robot Framework可以直接导入使用的库,包括: • Builtin:包含经常需要的关键字.自动导入无需import,因此总是可用的 • Dialogs:提供了暂停测试执行和从用户的 ...
- plSql添加快捷键设置
汉化版:工具-首选项-用户界面-编辑器-自动替换-定义文件 英文版:Tools->Perferences->Editor中Autoreplaces选择配置的shortcuts 常用快捷键设 ...
- inventor安装失败怎样卸载安装inventor 2017?
AUTODESK系列软件着实令人头疼,安装失败之后不能完全卸载!!!(比如maya,cad,3dsmax等).有时手动删除注册表重装之后还是会出现各种问题,每个版本的C++Runtime和.NET f ...
- PHP函数库(core)
数组函数: array_change_key_case — 返回字符串键名全为小写或大写的数组 array_change_key_case() 将 input 数组中的所有键名改为全小写或大写.改变是 ...
- LCS与打印路径
/* LCS */ #include<bits/stdc++.h> using namespace std; const int maxn = 1000; int dp[maxn][max ...
- react做股票、期货交易遇到的问题(不完全是react)及解决方法。
公司项目主要是做股票及期货行情展示及交易,h5相应的做了一些功能---可以看行情图及模拟交易,实盘交易存在一定的风险,老板希望做自己的产品,这样h5就尴尬了,不过没关系,项目里还是有一定技术含量的-- ...
- Linux下svn环境搭建
不久前买了一个阿里云服务器,想着在上面搭建一个svn服务方便自己的代码管理.顺便记录下自己的搭建过程 首先,安装服务 通过yum -stall subversion 安装snv,可能install之前 ...
- 移动端适配(1)——viewport设置与初始化css
<meta name="viewport" content="width=device-width,user-scalable=no,initial-scale=0 ...
- webpack优化技术参考
https://jeffjade.com/2017/08/12/125-webpack-package-optimization-for-speed/ 加速构建webpack.