摘要: 一开始用sort+binary_search,结果还是超时了,后来看到用lower_bound做。首先用map< int, vector<int> >,对每一个出现的数字用vector<int>记录出现位置,最后查找时如果位置不在vector里说明没有,若有相交的区间,说明有这个数。iterator lower_bound(beg, end, val):返回一个迭代器,它引用[beg, end)范围最低的位置,要求[beg, end)按照升序排列,此时插入val不会破坏该顺序。,如果val大于所有元素,返回end。 1 #include <iostre 阅读全文
posted @ 2013-03-29 22:09 PegasusWang 阅读(466) 评论(0) 推荐(0)