博客
关于我
2020.3.8普及C组 自动匹配(auto)【纪中】【二分】
阅读量:344 次
发布时间:2019-03-04

本文共 595 字,大约阅读时间需要 1 分钟。

一看到此题就觉得是一个二分

但由于 s t r i n g string string不好处理,所以又用了个 m a p map map.
m a p map map是个很实用的东西,我也不太会
所以有不懂的请问

**#include
#include
#include
#include
#include
//头文件要加using namespace std;int w,n,wh,j,k,l,r,mid;string s[30001],fi;map
cha; //定义mapint main(){ freopen("auto.in","r",stdin); freopen("auto.out","w",stdout); cin>>w>>n; for(int i=1; i<=w; i++) { cin>>s[i]; cha[s[i]]=i; } sort(s+1,s+1+w); for(int i=1; i<=n; i++) { cin>>wh>>fi; k=0,l=1,r=w; while(l<=r) //进行二分 { mid=(l+r)/2; if(s[mid]
w||s[l+wh-1].find(fi,0)) //实用的map cout<<-1<

转载地址:http://xjle.baihongyu.com/

你可能感兴趣的文章
MySQL 存储引擎
查看>>
mysql 存储过程 注入_mysql 视图 事务 存储过程 SQL注入
查看>>
MySQL 存储过程参数:in、out、inout
查看>>
mysql 存在update不存在insert
查看>>
Mysql 学习总结(86)—— Mysql 的 JSON 数据类型正确使用姿势
查看>>
Mysql 学习总结(89)—— Mysql 库表容量统计
查看>>
mysql 审核_审核MySQL数据库上的登录
查看>>
mysql 导入 sql 文件时 ERROR 1046 (3D000) no database selected 错误的解决
查看>>
mysql 常用命令
查看>>
Mysql 报错 Field 'id' doesn't have a default value
查看>>
MySQL 报错:Duplicate entry 'xxx' for key 'UNIQ_XXXX'
查看>>
mysql 数据库备份及ibdata1的瘦身
查看>>
MySQL 数据库备份种类以及常用备份工具汇总
查看>>
mysql 数据库存储引擎怎么选择?快来看看性能测试吧
查看>>
MySQL 数据库操作指南:学习如何使用 Python 进行增删改查操作
查看>>
MySQL 数据库的高可用性分析
查看>>
Mysql 数据库重置ID排序
查看>>
Mysql 数据类型一日期
查看>>
MySQL 数据类型和属性
查看>>
Mysql 整形列的字节与存储范围
查看>>