HDU 6040---Hints of sd0061(STL)】的更多相关文章

Hints of sd0061 Time Limit: 5000/2500 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 2262    Accepted Submission(s): 673 Problem Description sd0061, the legend of Beihang University ACM-ICPC Team, retired last yea…
/* HDU 6040 - Hints of sd0061 [ 第k小数查询,剪枝 ] 题意: 给出随机数列 a[N] (N < 1e7) 询问 b[M] (M < 100) ,对于每个询问输出第 b[i]+1小的数字 满足对任意 i,j,k,若b[i] <= b[k] && b[j] <= b[k] 则一定有 b[i]+b[j] <= b[k] 分析: 用 nth_element() 解决第k小数问题 先将询问排序,可以从小到大或从大到小解决,就能每次不断缩…
Hints of sd0061 Problem Description sd0061, the legend of Beihang University ACM-ICPC Team, retired last year leaving a group of noobs. Noobs have no idea how to deal with m coming contests. sd0061 has left a set of hints for them. There are n noobs…
Hints of sd0061 Time Limit: 5000/2500 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 2297    Accepted Submission(s): 687 Problem Description sd0061, the legend of Beihang University ACM-ICPC Team, retired last yea…
[题目链接] http://acm.hdu.edu.cn/showproblem.php?pid=6040 [题目大意] 给出一个随机数生成器,有m个询问,问第bi小的元素是啥 询问中对于bi<bk,bj<bk,有bi+bj<=bk [题解] (By Claris)对于所有的数字,我们将其按照高位分类,统计每个高16位有几个数字, 然后定位每个询问的高16位是什么,因为只有100个高16位是被询问到的, 把这100个高16位的数放入桶里,每次暴力查找,因为数据随机, 因此每个高16位期望…
[题目链接] http://acm.hdu.edu.cn/showproblem.php?pid=6040 [题目大意] 给出一个随机数生成器,有m个询问,问第bi小的元素是啥 询问中对于bi<bk,bj<bk,有bi+bj<=bk [题解] 我们将所有的询问排序,我们发现倒着处理询问的时候询问区间大小下降非常快, nth_element(start,start+k,end) 可以近似O(n)查询区间中第k小的数字, 并且在处理后保证比第k小小的数字均在其前面(虽然不一定有序), 所以我…
Hints of sd0061 Time Limit: 5000/2500 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 2421    Accepted Submission(s): 736 Problem Description sd0061, the legend of Beihang University ACM-ICPC Team, retired last yea…
Hints of sd0061 Time Limit: 5000/2500 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 492    Accepted Submission(s): 106 Problem Description sd0061, the legend of Beihang University ACM-ICPC Team, retired last year…
题目链接 Problem Description sd0061, the legend of Beihang University ACM-ICPC Team, retired last year leaving a group of noobs. Noobs have no idea how to deal with m coming contests. sd0061 has left a set of hints for them. There are n noobs in the team…
Train Problem I Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 41471    Accepted Submission(s): 15510 Problem Description As the new term comes, the Ignatius Train Station is very busy nowaday…
Expression Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 202    Accepted Submission(s): 61 Problem Description   As a shopkeeper of a restaurant,everyday ,dandelion's mother needs to calculat…
题目 //把所有的出现的名字开始默认都为冠军(1),然后输了的置为0,表示不为冠军,最后统计不为0的, //当有且只有一个不为0的,这个就为冠军,否则,不能产生冠军. //以上思路来自别人的博客.. //set可以去重,所以这里用了set //set可以去重,并且自动排序 //数set元素个数要用 s.size() 的啊 #include<stdio.h> #include<string.h> #include<algorithm> #include<iostre…
Problem Description 圆桌上围坐着2n个人.其中n个人是好人,另外n个人是坏人.如果从第一个人开始数数,数到第m个人,则立即处死该人:然后从被处死的人之后开始数数,再将数到的第m个人处死……依此方法不断处死围坐在圆桌上的人.试问预先应如何安排这些好人与坏人的座位,能使得在处死n个人之后,圆桌上围坐的剩余的n个人全是好人.   Input 多组数据,每组数据输入:好人和坏人的人数n(<=32767).步长m(<=32767):   Output 对于每一组数据,输出2n个大写字…
Problem Description The annual school bicycle contest started. ZL is a student in this school. He is so boring because he can't ride a bike!! So he decided to interfere with the contest. He has got the players' information by previous contest video.…
Holedox Eating Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2862    Accepted Submission(s): 952 Problem Description Holedox is a small animal which can be considered as one point. It lives in…
Revenge of Collinearity Time Limit: 8000/5000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 612    Accepted Submission(s): 207 Problem Description In geometry, collinearity is a property of a set of points, specifi…
人见人爱A-B Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 95146    Accepted Submission(s): 26564 Problem Description 参加过上个月月赛的同学一定还记得其中的一个最简单的题目,就是{A}+{B},那个题目求的是两个集合的并集,今天我们这个A-B求的是两个集合的差,就是做集合的减…
Electronic Document Security Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 172    Accepted Submission(s): 94 Problem Description The Tyrell corporation uses a state-of-the-art electronic docu…
题意略. 思路:题目就是在询问你m次,第k小是哪个数.首先我们可以想到直接排序后,即可O(1)来查找询问.但是题目中n的范围给的是1e7, 无法承受nlogn的复杂度.从而想到另外一种求静态第k小的方法:利用快速排序来做到.时间复杂度是O(n),但是询问次数m是100, 同样无法承受O(n * m)的复杂度.这时我们应该想到题目中给的另外一个条件:if (bi < bk && bj < bk  && bi != bk) then bi + bj <= bk…
产生冠军 Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 26204    Accepted Submission(s): 11751 Problem Description 有一群人,打乒乓球比赛,两两捉对撕杀,每两个人之间最多打一场比赛.球赛的规则如下:如果A打败了B,B又打败了C,而A与C之间没有进行过比赛,那么就认定,A一定能打败…
题目链接:https://vjudge.net/problem/HDU-6040 题目大意: 给出 \(n\) 个数,有 \(m\) 次询问,每次询问这 \(n\) 个数中第 \(k+1\) 大的数是什么. 另有附加限制:对于 \(n\) 个数中的任意三个数 \(a,b,c\),如果满足 \(a \not= b, a < c, b < c\),则有 \(a + b \le c\). \((1 \le n \le 10^{7}, 1 \le m \le 100)\) 解题思路: 由附加限制不难联…
题目链接  http://acm.hdu.edu.cn/showproblem.php?pid=2072 普通解法: /* HDU 2072 单词数 --- 字符串处理 */ #include <cstdio> //C语言改成stdio.h即可 #include <cstring> //C语言改成string.h即可 ; int main() { char *head1, *head2; char a[maxn]; char b[maxn][maxn]; int i, k, len…
这几天做了几道随机生成数组的题,且需要用nth-elemeng函数,并且都是北航出的多校题…… 首先我们先贴一下随机生成数组函数的代码: unsigned x = A, y = B, z = C; unsigned rng61() { unsigned t; x ^= x << ; x ^= x >> ; x ^= x << ; t = x; x = y; y = z; z = t ^ x ^ y; return z; } 这个函数的原理原谅我不太懂,就不多说了-_-|…
2017 Chinese Multi-University Training, BeihangU Contest Add More Zero 思路:log10(2^m) = m*log10(2) 代码: #pragma GCC optimize(2) #pragma GCC optimize(3) #pragma GCC optimize(4) #include<bits/stdc++.h> using namespace std; #define y1 y11 #define fi firs…
Hyperspace Time Limit: 20000/10000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others)Total Submission(s): 1023    Accepted Submission(s): 492 Problem Description The great Mr.Smith has invented a hyperspace particle generator. The device i…
pog loves szh II Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5265 Description pog在与szh玩游戏,首先pog找到了一个包含n个数的序列,然后他在这n个数中挑出了一个数A,szh出于对pog的爱,在余下的n−1个数中也挑了一个数B,那么szh与pog的恩爱值为(A+B)对p取模后的余数,pog与szh当然想让恩爱值越高越好,并且他们…
Let the Balloon Rise Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 123800    Accepted Submission(s): 48826 Problem Description Contest time again! How excited it is to see balloons floating ar…
给出两个图,问你是不是同构的... 直接通过并查集建图,暴力用SET判断下子节点个数就行了. /** @Date : 2017-09-22 16:13:42 * @FileName: HDU 3926 并查集 图同构 连通分量.cpp * @Platform: Windows * @Author : Lweleth (SoungEarlf@gmail.com) * @Link : https://github.com/ * @Version : $Id$ */ #include <bits/st…
HDOJ(HDU).1412 {A} + {B} (STL SET) 点我挑战题目 题意分析 大水题,会了set直接用set即可. 利用的是set的互异性(同一元素有且仅有一项). #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <set> #define nmax 20005 using namespace std; s…
题目链接:HDU Today 立即集训要開始,抓紧时间练练手,最短路的基础题,第一次用STL的map 题目非常水,可是错了N遍.手贱了.本题不优点理的就是把地名转化为数字 #include <iostream> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <map> #define N 155 #define INF 1e7 using namespace…