博客
关于我
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/

你可能感兴趣的文章