BZOJ2138 : stone】的更多相关文章

Description 话说Nan在海边等人,预计还要等上M分钟.为了打发时间,他玩起了石子.Nan搬来了N堆石子,编号为1到N,每堆 包含Ai颗石子.每1分钟,Nan会在编号在\([L_i,R_i]\)之间的石堆中挑出任意Ki颗扔向大海(好疼的玩法),如果\([L_i,R_i]\)剩下石子不够\(K_i\)颗,则取尽量地多.为了保留扔石子的新鲜感,Nan保证任意两个区间\([L_i,R_i]\)和\([L_j,R_j]\),不会存在\(L_i<=L_j\& R_j<=R_i\)的情况…
根据Hall定理,若存在一个区间满足内部需求数$>$内部石子数,则不存在完美匹配. 由于区间互不包含,所以设: $a[i]$表示右端点$\leq i$的区间的容量之和. $b[i]$表示左端点$\leq i$的区间的容量之和. $s[i]$表示前$i$个位置的石子数之和. 则区间$[l,r]$的: 石子数$=s[r]-s[l-1]$. 需求数$=a[r]-b[l-1]$. 即对于任意$0\leq i<j\leq n$,要满足: $\min((s[j]-a[j])-(s[i]-b[i]))\ge…
题意 一共有 \(n\) 堆石子,每堆石子有一个数量 \(a\) ,你要进行 \(m\) 次操作,每次操作你可以在满足前 \(i-1\) 次操作的回答的基础上选择在 \([L_i,R_i]\) 区间中拿走至多 \(b\) 颗石子,保证区间不存在包含关系,求每次你最多拿走多少颗石子. \(n\le 4\times 10^4\) 分析 二分图匹配复杂度太高,考虑霍尔定理. 假设某次操作时我们已经知道了每次操作取走多少颗石子,我们选择判断的操作集合一定是按 \(L\) 排序之后连续的(因为能够选择的区…
[BZOJ2138]stone Description 话说Nan在海边等人,预计还要等上M分钟.为了打发时间,他玩起了石子.Nan搬来了N堆石子,编号为1到N,每堆包含Ai颗石子.每1分钟,Nan会在编号在[Li,Ri]之间的石堆中挑出任意Ki颗扔向大海(好疼的玩法),如果[Li,Ri]剩下石子不够Ki颗,则取尽量地多.为了保留扔石子的新鲜感,Nan保证任意两个区间[Li,Ri]和[Lj,Rj],不会存在Li<=Lj&Rj<=Ri的情况,即任意两段区间不存在包含关系.可是,如果选择不…
[BZOJ2138]stone(线段树,Hall定理) 题面 BZOJ 题解 考虑一个暴力. 我们对于每堆石子和每个询问,显然是匹配的操作. 所以可以把石子拆成\(a_i\)个,询问点拆成\(K_i\)个,这样就是每次进行一次二分图的匹配. 当然可以用网络流+线段树优化连边来做,但是这样复杂度太高. 还是回到二分图的匹配问题,我们现在要验证的就是是否存在对于当前询问点的完美匹配. 关于完美匹配,有\(Hall\)定理,如果存在完美匹配,假设左侧的点有\(|X|\)个,那么这些点连向右边的点的点集…
传送门 题意: 现在有\(n\)堆石子,每堆石子有\(a_i\)个. 之后会有\(m\)次,每次选择\([l,r]\)的石子堆中的石子扔\(k\)个,若不足,则尽量扔. 现在输出\(1\)~\(m\)次,每次最多能取到多少石子(输出第\(i\)次的情况时,要考虑前\(i-1\)次). 给出的区间不存在包含关系. 思路: 稍微暴力点想就是一个二分图,将\(k_i\)拆在左边,然后石子在右边,每次最大匹配. 但这做法显然不可行,时间复杂度不能承受. 这种一般就考虑\(hall\)定理:假设前面都满足…
题目 好厉害的题啊 这道题不难看成一个二分图模型,但是给人一种求最大匹配的感觉,这实在不是很好求的样子,于是自闭了 但是不妨这样来考虑,对于一个需求\(k_i\),我们求一个最大的\(x\leq k_i\),使得这张图存在完美匹配就好了,这样我们就能愉快的使用hall定理了 我们把所有区间排个序,由于保证了没有包含关系,所以左.右端点都是单调的: 众所周知hall定理要求的是子集,但子集显然不是很好求的样子:而这个题的特殊性质可以使我们只考虑区间的情况,至于为什么,还是比较显然的. 设第\(i\…
A New Stone Game Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 5769   Accepted: 3158 Description Alice and Bob decide to play a new stone game.At the beginning of the game they pick n(1<=n<=10) piles of stones in a line. Alice and Bob…
1.题目: 1180. Stone Game Time limit: 1.0 secondMemory limit: 64 MB Two Nikifors play a funny game. There is a heap of N stones in front of them. Both Nikifors in turns take some stones from the heap. One may take any number of stones with the only cond…
Zhuge Liang's Stone Sentinel Maze Time Limit: 10000/4000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 385    Accepted Submission(s): 106 Problem Description Zhuge Liang was a chancellor of the state of Shu Han dur…
A New Stone Game Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 5453   Accepted: 2989 Description Alice and Bob decide to play a new stone game.At the beginning of the game they pick n(1<=n<=10) piles of stones in a line. Alice and Bob…
F - Again Stone Game Time Limit:2000MS     Memory Limit:32768KB     64bit IO Format:%lld & %llu Submit Status Description Alice and Bob are playing a stone game. Initially there are n piles of stones and each pile contains some stone. Alice stars the…
Lifting the Stone Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Status Practice HDU 1115 Description There are many secret openings in the floor which are covered by a big heavy stone. When the stone is lifted up…
http://poj.org/problem?id=1740 题目大意就是,对于n堆石子,每堆若干个,两人轮流操作,每次操作分两步,第一步从某堆中去掉至少一个,第二步(可省略)把该堆剩余石子的一部分分给其它的某些堆.最后谁无子可取即输. 看了题解感觉太神了. 首先我们来分析: 当只有一堆时,先手必胜,直接一次取完即可 当有两堆时,分两种情况,一是两堆相同时,先手必输,因为无论先手怎样取,后手总有办法再次平衡两堆:而是两堆不同时,先手必胜,因为先手总有办法先平衡两堆,然后就像一的情况. 当有三堆时…
A simple stone game                                                                                                       Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)                                             …
A New Stone Game 题意: 对于n堆石子,每堆若干个,两人轮流操作,每次操作分两步,第一步从某堆中去掉至少一个,第二步(可省略)把该堆剩余石子的一部分分给其它的某些堆.最后谁无子可取即输. 题解: 首先我们考虑两堆相等的情况,一定是谁取谁输,因为对方永远可以做对称的操作.对于四堆,1.2堆相等,3.4堆相等的情况,一定也是先手输,后手也只需要做对称的操作(在先手取石子的对称堆中取相同多的石子,并把和先手等量的石子分给先手分配给的堆的对称堆.(若先手在3堆取,并分给1堆,那后手就在4…
题目链接 A Sample Stone Game 题目大意:给定n,k,表示最初时有n个石头,两个人玩取石子游戏,第一个人第一次可以取1~n-1个石头,后面每个人最多可以拿走前面一个人拿走的个数的K倍,当有一个人可以一次性全部拿走时获胜.问两人都在不失误的情况下,先拿着有没有必胜局势.有的话求他第一次最少该取多少个. 思考过程: 首先讨论k=1的情况,我们可以把一个数n(石子的个数),写为二进制下的表示,那先者取走最后一个1,那后者必然不能取走比它高一位的1,那么先拿者一定会赢,当然如果n本来就…
题目: E - A simple stone game Time Limit:1000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u Submit Status Practice POJ 3922 Description After he has learned how to play Nim game, Mike begins to try another stone game which seems much eas…
[题目] Description The funny stone game is coming. There are n piles of stones, numbered with 0, 1, 2, ..., n − 1. Twopersons pick stones in turn. In every turn, each person selects three piles of stones numbered i, j, k(i < j, j ≤ k and at least one s…
A New Stone Game Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 5694   Accepted: 3119 Description Alice and Bob decide to play a new stone game.At the beginning of the game they pick n(1<=n<=10) piles of stones in a line. Alice and Bob…
A New Stone Game Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 5338   Accepted: 2926 Description Alice and Bob decide to play a new stone game.At the beginning of the game they pick n(1<=n<=10) piles of stones in a line. Alice and Bob…
Lifting the Stone Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 6104    Accepted Submission(s): 2546 Problem Description There are many secret openings in the floor which are covered by a big…
1180. Stone Game Time limit: 1.0 second Memory limit: 64 MB Two Nikifors play a funny game. There is a heap of N stones in front of them. Both Nikifors in turns take some stones from the heap. One may take any number of stones with the only condition…
UVA 10165 - Stone Game 题目链接 题意:给定n堆石子,每次能在一堆取1到多个.取到最后一个赢,问谁赢 思路:就裸的的Nim游戏,利用定理求解 代码: #include <stdio.h> #include <string.h> int n, num; int main() { while (~scanf("%d", &n) && n) { int sum = 0; for (int i = 0; i < n;…
外语学习强烈推荐Rosetta Stone 外语学习强烈推荐Rosetta Stone…
题目: Lifting the Stone Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 168 Accepted Submission(s): 98   Problem Description There are many secret openings in the floor which are covered by a big he…
DP: dp[i][j]前i堆放j序列长度有多少行法, dp[i][j]=dp[i-1][j] (不用第i堆), dp[i][j]+=dp[i-1][j-k]*C[j][k] (用第i堆的k个石头) A Famous Stone Collector Time Limit: 30000/15000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 845    Accepted Su…
题目链接:hdu 5996 dingyeye loves stone 题意: 给你一棵树,树的每一个节点有a[i]个石子,每个人可以将这个节点的石子移向它的父亲,如果没有合法操作,那么就算输,现在给你当前的局面,问你能否赢 题解: 设根节点的深度为0,将所有深度为奇数的节点的石子数目xor起来,则先手必胜当且仅当这个xor和不为0. 证明同阶梯博弈.对于偶深度的点上的石子,若对手移动它们,则可模仿操作:对于奇深度上的石子,移动一次即进入偶深度的点. 时空复杂度O(n). #include<bit…
Problem Description There are many secret openings in the floor which are covered by a big heavy stone. When the stone is lifted up, a special mechanism detects this and activates poisoned arrows that are shot near the opening. The only possibility i…
Alice and Bob are playing a stone game. Initially there are n piles of stones and each pile contains some stone. Alice stars the game and they alternate moves. In each move, a player has to select any pile and should remove at least one and no more t…