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 ...
随机推荐
- ECharts基本设置
theme = { // 全图默认背景 // backgroundColor: ‘rgba(0,0,0,0)’, // 默认色板 color: ['#ff7f50','#87cefa','#da70d ...
- transient关键字与序列化、反序列化
transient,中文翻译是短暂的,和对象序列化.反序列化有关. 一个类只要实现了Serializable接口,则该类实例就可以序列化,具体来说实例的每个非静态成员变量都会序列化.注意是非静态成员变 ...
- Mybatis学习笔记12 - 动态sql之choose(when otherwise)标签
choose (when, otherwise):分支选择:带了break的swtich-case 示例代码: 接口定义: package com.mybatis.dao; import com.my ...
- Android NDK开发 图片处理(五)
做过Java的同学可能经常会遇到一些关于图片处理的 例如类似QQ离线头像显示灰的.最快的算法是用colorMatrix来实现.这里通过Java调用JNI来处理每一个像素来实现. 对每一个像素点取出RG ...
- python 读取文件使用chunksize后逐块迭代操作
chunkers=pd.read_csv('dd.csv',chunksize=10000) tot=pd.Series([]) for piece in chunkers: tot=tot.add( ...
- IOS Intro - NSDictionary and NSMutableDictionary
NSDictionary.NSMutableDictionary的基本用法 1.不可变词典NSDictionary 字典初始化 NSNumber *numObj = [NSNumber numberW ...
- ThreadLocal 开启事务
1.ThreadLocal该类提供了线程局部变量 2.分析原理: ThreadLocal内部有一个Map.Map的key是当前线程对象,value是一个Object对象. 模拟该类: public c ...
- 关于Vim 的插件snipmate 以及它的安装方式
在网上看了http://study.163.com/course/courseMain.htm?courseId=269016#/courseMain 里关于snipmate 的视频 snipma ...
- c#获取目录2
// 获取程序的基目录. System.AppDomain.CurrentDomain.BaseDirectory // 获取模块的完整路径. System.Diagnostics.Process.G ...
- SQL Server和ASP.NET的操作基本操作
ado.net提供了丰富的数据库操作,这些操作可以分为三个步骤: 第一,使用SqlConnection对象连接数据库: 第二,建立SqlCommand对象,负责SQL语句的执行和存储过程的调用: 第三 ...