ural 1613【hash+二分】
来源:互联网 发布:许巍和汪峰 知乎 编辑:程序博客网 时间:2024/05/16 03:50
http://acm.timus.ru/problem.aspx?space=1&num=1613
hash+二分,其中hash可以用STL里面的map实现。开始没注意到原来那个序号是有序的!!!所以用vector就ok
#include <vector>#include <list>#include <map>#include <set>#include <queue>#include <string.h>#include <deque>#include <stack>#include <bitset>#include <algorithm>#include <functional>#include <numeric>#include <utility>#include <sstream>#include <iostream>#include <iomanip>#include <cstdio>#include <cmath>#include <cstdlib>#include <limits.h>using namespace std;#define LL long long#define pi acos(-1)#define N 5000#define INF INT_MAX#define eps 1e-8//*********************************************//ural 1613//*********************************************map<int,vector<int> > mp;int main(){ //freopen("a.txt","r",stdin); int n; while(scanf("%d",&n)!=EOF) { int i,j,k; for(i=1;i<=n;i++) { int a; scanf("%d",&a); mp[a].push_back(i); } int m; scanf("%d",&m); while(m--) { int l,r,z; scanf("%d%d%d",&l,&r,&z); int sz=mp[z].size(); if(sz==0) { printf("0"); continue; } int flag=0; int low=0,up=sz-1,mid; while(low<=up) { mid=(low+up)>>1; if(mp[z][mid]>=l && mp[z][mid]<=r) { flag=1; break; } if(mp[z][mid]<l) low=mid+1; if(mp[z][mid]>r) up=mid-1; } if(flag)printf("1"); else printf("0"); } printf("\n"); mp.clear(); } return 0;}
- ural 1613【hash+二分】
- URAL - 1066 Garland(二分)
- URAL 1133 二分
- ural 1052. Rabbit Hunt hash
- URAL 1153. Supercomputer 二分求根
- Ural 1542. Autocompletion(二分)
- 【二分答案&&最短路】URAL
- hdu_1496_equations( 二分 or hash )
- BZOJ2258【hash】【二分】
- bzoj 1692 二分+hash
- 字符串hash + 二分答案
- hdu6138 hash+二分
- Ural 1486. Equal Squares 字符串hash
- URAL 1486(二维字符串hash)
- ural 1989(树状数组+多项式hash)
- hash(二分+hash)使用map会tle
- URAL 1229贴地砖 . 二分图匹配
- Ural 1428. Jedi Riddle 二分求幂
- Smarty快速入门之三 填充Select元素
- /usr/lib/libexpat.so: could not read symbols解决方法
- VC list control中设置某行选中
- 算法问题集
- C++设计模式-工厂方法
- ural 1613【hash+二分】
- 51单片机普通IO口模拟IIC总线的程序实现
- Powershell 操作hyper-v 一般性操作
- WebView loadData出错(奇怪的设计)
- 做游戏用
- 学习C#.net
- 社会心理学书籍《别做正常的傻瓜》全书精彩语句摘录
- 如何判断一个int型整数n为2的整数次幂
- Linux开机自动挂载Windows分区的两种方法