hdu 5233 Gunner II】的更多相关文章

原题链接:http://acm.hdu.edu.cn/showproblem.php?pid=5233 简单题,stl水之... #include<algorithm> #include<iostream> #include<cstdlib> #include<cstdio> #include<set> using std::multiset; struct Node { int val, pos; Node(, ) :val(_val), po…
题目链接: hdu:http://acm.hdu.edu.cn/showproblem.php?pid=5233 bc(中文):http://bestcoder.hdu.edu.cn/contests/contest_chineseproblem.php?cid=585&pid=1002 题解: 离散化之后,存在一张表里面(相同的值的id号用链表串起来,倒着存),每次查询完就把表首的删了,继续查. 之前离散的时候没有把查询的一起加进去,就一直t,估计是查询的时候很多是没有结果的,就会比较耗时间.…
题目传送门 /* 题意:查询x的id,每次前排的树倒下 使用lower_bound ()查找高度,f[i]记录第一棵高度为x树的位置,查询后+1(因为有序) */ #include <cstdio> #include <algorithm> #include <cstring> using namespace std; ; const int INF = 0x3f3f3f3f; struct A { int v, id; bool operator < (cons…
Gunner II Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 1740    Accepted Submission(s): 635 Problem Description Long long ago, there was a gunner whose name is Jack. He likes to go hunting ve…
HDU 3567 Eight II(八数码 II) /65536 K (Java/Others)   Problem Description - 题目描述 Eight-puzzle, which is also called "Nine grids", comes from an old game. In this game, you are given a 3 by 3 board and 8 tiles. The tiles are numbered from 1 to 8 and…
HDU 2236 无题II 题目链接 思路:行列仅仅能一个,想到二分图,然后二分区间长度,枚举下限.就能求出哪些边是能用的,然后建图跑二分图,假设最大匹配等于n就是符合的 代码: #include <cstdio> #include <cstring> #include <vector> #include <algorithm> using namespace std; const int N = 105; int t, n, x[N][N], have[N…
Sequence II Time Limit: 9000/4500 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others) Total Submission(s): 1422    Accepted Submission(s): 362 Problem Description Mr. Frog has an integer sequence of length n, which can be denoted as a1,a2…
Eight II Time Limit: 2000ms Memory Limit: 65536KB This problem will be judged on HDU. Original ID: 356764-bit integer IO format: %I64d      Java class name: Main   Eight-puzzle, which is also called "Nine grids", comes from an old game. In this…
Sequence II Problem Description   Mr. Frog has an integer sequence of length n, which can be denoted as a1,a2,⋯,an There are m queries. In the i-th query, you are given two integers li and ri. Consider the subsequence ali,ali+1,ali+2,⋯,ari. We can de…
FXTZ II Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 498    Accepted Submission(s): 266 Problem Description Cirno is playing a fighting game called "FXTZ" with Sanae.  Sanae is a ChuSho…
http://acm.hdu.edu.cn/showproblem.php?pid=3085 出的很好的双向bfs,卡时间,普通的bfs会超时 题意方面: 1. 可停留 2. ghost无视墙壁 3. 需要检查两次某个地点是否有ghost,正要到达的时候(t),以及即将启程的时候(t+1). 在编程时需要注意的是: 当两个人汇合时,不需要检查即将启程的那次. M可以走3步,在这3步中间只需要检查是否能到达(t) 出问题在: 1. 检查时间处理的不清晰 2.普通bfs会超时 3.双向bfs需要完全…
http://acm.hdu.edu.cn/showproblem.php?pid=3567 相比Eight,似乎只是把目标状态由确定的改成不确定的,但是康托展开+曼哈顿为h值的A*和IDA*都不过,而且也不好控制字典序 换个角度想,虽然起始状态有很多,但是到底哪一位是1,哪一位是2不是最重要的,最重要的是和目标状态对应,所以可以把起始状态重新编码为"12345678"这种形式(先不考虑X),然后目标状态也对应过去,当考虑X的时候,我们可以认为起始状态只有9种,分别是'X'在各个位置的…
原题链接:http://acm.hdu.edu.cn/showproblem.php?pid=5199 简单题,stl水之... #include<algorithm> #include<iostream> #include<cstdlib> #include<cstring> #include<cstdio> #include<set> #include<map> using std::map; map<int,…
题意: 给一串数字,每个数字的位置是这个数第一次出现的位置. 每个询问对于序列的一个子区间,设一共有k个不同的数,求第ceil(k/2)个数的位置. 因为强制在线,所以离线乱搞pass掉. 主席树可解. 考虑一个数列: p      1 2 3 4 5 6  // 原序列标号 a : 1 2 1 2 3 4  // 原序列 p1 1 2 1 2 5 6  // 子序列开始下标为1 p2        2 3 1 5 6 p3           3 4 5 6 p4              4…
[题目] Tree chain problem Problem Description Coco has a tree, whose vertices are conveniently labeled by 1,2,-,n.There are m chain on the tree, Each chain has a certain weight. Coco would like to pick out some chains any two of which do not share comm…
http://acm.hdu.edu.cn/showproblem.php?pid=5147 题意:问有多少个这样的四元组(a,b,c,d),满足条件是 1<=a<b<c<d; Aa<Ab; Ac<Ad; 思路:用树状数组求,从右向左求在这个数之前形成多少个逆序数对记录在r数组里面,然后在从左向右求出在输入这个数之前形成多少个逆序数对存在l数组里面,然后枚举b就行: #include <cstdio> #include <cstring> #in…
Problem Description Long long ago, there is a gunner whose name is Jack. He likes to go hunting very much. One day he go to the grove. There are n birds and n trees. The i−thbird stands on the top of the i−th tree. The trees stand in straight line fr…
职务地址:http://acm.hdu.edu.cn/showproblem.php? pid=3081 有一段时间没写最大流的题了,这题建图竟然想了好长时间... 刚開始是按着终于的最大流即是做多轮数去想建图,结果根本没思路.后来想了想,能够用二分答案的思想来找终于答案.然后非常明显的并查集,可是并查集学的略渣,竟然卡在并查集上了..= =. 可是也不是并查集的事. .是我建图的思想太正了,略微用点逆向思维并查集就能够非常好利用了. 建图思路是:建立一个源点与汇点,将女孩与源点相连,男孩与汇点…
[题目链接]http://acm.hdu.edu.cn/showproblem.php?pid=5919 [题目大意] 给出一个数列,每次查询数列中,区间非重元素的下标的中位数.查询操作强制在线. [题解] 因为查询的是下标,因此,我们直接在下标操作表示这里有没有数字,然后查询k大数即可,非重元素即需要在区间每个数第一次出现的地方+1,然后对处理完的区间进行查询即可,考虑到查询强制在线,不能扫描线,因此只能建立可持久化线段树,线段树的第i个版本表示第i个位置往后的每个元素第一次出现的位置,那么查…
[题目链接] http://acm.hdu.edu.cn/showproblem.php?pid=5823 [题目大意] 定义一张无向图的价值:给每个节点染色使得每条边连接的两个节点颜色不相同的最少颜色数. 对于给定的一张由n个点组成的无向图,求该图的2^n-1张非空子图的价值. [题解] 设f[i][S]表示i种颜色覆盖S这个集合的方案数,我们只要得到最小的i,f[i][S]大于0,那么i就是S集合的答案.显然有f[i][S]=∑f[1][u]×f[i−1][v](u|v==S),这个怎么求呢…
链接:http://acm.hdu.edu.cn/showproblem.php?pid=5919 大致题意: 给你一个长度为n的序列,q个询问,每次询问是给你两个数x,y,经过与上一次的答案进行运算会得到一个区间[x,y],假设这个区间内有k个数,对k个数第一次出现的位置进行排序取第(k+1)/2个数. 思路: 看题意可知要求的是区间不同数的个数和区间第k小,强制在线, 之前正好写过求区间不同数的个数的三种解法:离线树状数组,主席树,莫队,因为这道题是强制在线,莫队和离线树状数组都不能用,这里…
http://acm.split.hdu.edu.cn/showproblem.php?pid=5919 题意:给出一串序列,每次给出区间,求出该区间内不同数的个数k和第一个数出现的位置(将这些位置组成一个新的序列),输出这里面的第ceil(k/2)个数. 思路: 因为每个区间只需要统计第一个数出现的位置,那么从右往左来建树,如果该数没有出现,那么就将该位置+1,否则要将上一次出现的位置-1后再在该位置+1. 统计不同数的个数很简单,就是线段树查询. 查询出第k小的数也很简单,因为我们是从后往前…
题目链接: pid=2236">Hdu 2236 解题思路: 将行和列理解为二分图两边的端点,给出的矩阵即为二分图中的全部边, 假设二分图能全然匹配,则说明 不同行 不同列的n个元素 区间为(min_edge.max_edge),这些edge是指构成全然匹配的那些边 题目须要求解最小区间长度 我们 能够 二分区间长度(0~100),每次枚举区间的下界 最后得到的maxl 即为答案 代码: #include<iostream> #include<cstdio> #in…
Sequence II Time Limit: 5000/2500 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Problem Description Long long ago, there is a sequence A with length n. All numbers in this sequence is no smaller than 1 and no bigger than n, and all nu…
题目链接 Sequence II Time Limit: 5000/2500 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 331    Accepted Submission(s): 151 Problem Description Long long ago, there is a sequence A with length n. All numbers in this se…
传送门 FXTZ II Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 530    Accepted Submission(s): 280 Problem Description Cirno is playing a fighting game called "FXTZ" with Sanae. Sanae is a ChuS…
题目:http://acm.hdu.edu.cn/showproblem.php?pid=5823 看博客:http://www.cnblogs.com/SilverNebula/p/5929550.html 学到了求子集中独立集的姿势~ 还有那个子集DP真是太妙了! 代码如下: #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> using namespace…
HDU 5919 题意: 动态处理一个序列的区间问题,对于一个给定序列,每次输入区间的左端点和右端点,输出这个区间中:每个数字第一次出现的位子留下, 输出这些位子中最中间的那个,就是(len+1)/2那个. 思路: 主席树操作,这里的思路是从n到1开始建树.其他就是主席树查询区间第K小,计算区间不同值个数. #include <algorithm> #include <iterator> #include <iostream> #include <cstring&…
题目:http://acm.hdu.edu.cn/showproblem.php?pid=5823 独立集染一种颜色.在这个基础上枚举子集来dp. 状压一样地存边真是美妙. 2^32是1ll<<32,不是1<<31. #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> #define ll long long using namespace…
Sequence IITime Limit: 5000/2500 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Problem DescriptionLong long ago, there is a sequence A with length n. All numbers in this sequence is no smaller than 1 and no bigger than n, and all numbers…