【题解】Cutting Game】的更多相关文章

[题解]Cutting Game vjudge 谈谈对\(sg\)函数的理解? 浅谈公平组合游戏IGC //@winlere #include<cstring> #include<cstdio> using namespace std; typedef long long ll; const int maxn=201; int temp[maxn]; int sg[maxn][maxn],a,b; int main(){ for(register int n=2;n<=200…
题意:有1~n个小环,他们中的有些互相扣在一起,问你至少切开几个能把这写小环串成一条链 思路:还是太菜了,题目给的n<=15,显然可以暴力解决. 用二进制表示每个环切还是不切,然后搜索所有情况.当一种情况满足一下两点:1.切完之后每一串连在一起的环应该是一条链,没有分支没有环:2.当一个环被切开,那么他就可以当做任意串的连接点,那么显然切开的点+1>=串的数量. 代码: #include<set> #include<map> #include<stack>…
思路:dfs找先手必胜的情况是否存在 代码: #include<stack> #include<vector> #include<queue> #include<set> #include<cstring> #include<string> #include<sstream> #include<iostream> #include<cstdio> #include<cmath> #inc…
题意: 标记为\(1-n\)的竹子,\(q\)个询问,每次给出\(l,r,x,y\).要求为砍区间\(l,r\)的柱子,要求砍\(y\)次把所有竹子砍完,每次砍的时候选一个高度,把比他高的都砍下来,并且这\(y\)次砍下来长度都相等,问第\(x\)次砍在什么高度. 思路: 显然就是要求选一个高度砍,使得剩下的高度为\((sum[r] - sum[l - 1]) - (sum[r] - sum[l - 1])/y * x\),那么直接建好主席树,然后二分出这个高度. 主席树好啊. 代码: #inc…
Content 求用 \(n\) 条直线最多能将平面分成多少块区域. 多组输入,以一个负数结束. 数据范围:\(0\leqslant n\leqslant 2.1\times 10^8\). Solution 小学奥数题. 首先你得要知道 \(1+2+...+n=\dfrac{n(n+1)}{2}\). 我们先通过画图来找一下规律. 不切,此时很显然总共有 \(1\) 个区域. 切一刀,此时最多有 \(2\) 个区域. 切两刀,此时最多有 \(4\) 个区域. 切三刀,此时最多只能有 \(7\)…
Cutting Game 题意: 有一张被分成 w*h 的格子的长方形纸张,两人轮流沿着格子的边界水平或垂直切割,将纸张分割成两部分.切割了n次之后就得到了n+1张纸,每次都可以选择切得的某一张纸再进行切割.最先切出只有一个格子的纸张(即有 1*1 格子的)的一方获胜.当双方都采取最优策略时,先手必胜还是必败? 题解: 这题是小白书上的,在取得游戏中必胜策略的最后一题,我照着码一遍就叫了,结果居然T了,,最后发现是cin的问题,然后关下同步就可以a了,但好险用了913ms... 还有初始化mem…
Tree Cutting Problem Description Byteasar has a tree T with n vertices conveniently labeled with 1,2,...,n. Each vertex of the tree has an integer value vi.The value of a non-empty tree T is equal to v1⊕v2⊕...⊕vn, where ⊕ denotes bitwise-xor.Now for…
3391: [Usaco2004 Dec]Tree Cutting网络破坏 Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 47  Solved: 37[Submit][Status] Description     约翰意识到贝茜建设网络花费了他巨额的经费,就把她解雇了.贝茜很愤怒,打算狠狠报 复.她打算破坏刚建成的约翰的网络.    约翰的网络是树形的,连接着N(1≤N≤10000)个牛棚.她打算切断某一个牛棚的电源,使和这个牛棚相连的所有电缆全…
3391: [Usaco2004 Dec]Tree Cutting网络破坏 Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 76  Solved: 59[Submit][Status][Discuss] Description     约翰意识到贝茜建设网络花费了他巨额的经费,就把她解雇了.贝茜很愤怒,打算狠狠报 复.她打算破坏刚建成的约翰的网络.    约翰的网络是树形的,连接着N(1≤N≤10000)个牛棚.她打算切断某一个牛棚的电源,使和这个牛…
题目链接:Cutting Out 题意:给定一个n长度的数字序列s,要求得到一个k长度的数字序列t,每次从s序列中删掉完整的序列t,求出能删次数最多的那个数字序列t. 题解:数字序列s先转换成不重复的数字序列,并记录各个数字重复的次数,然后按照重复次数从大到小排序.二分最大删除次数,最后再输出对应的序列t. #include <map> #include <cstdio> #include <iostream> #include <algorithm> us…
这场有点难,QAQ.补了好久(。• ︿•̀。) ,总算能写题解了(つд⊂) A. Beautiful numbers CodeForces - 55D 题意 ​ 求\([l,r](1\le l_i\le r_i\le 9\cdot 10^{18})\)的中的 可以被自己每一位上的数字整除的数 的个数. 题解: ​ 知识:如果m%a=0,则任意x, x%a = (x%m)%a. ​ 2520是2~9的lcm.因此任何时候都有2520%pre_lcm==0. ​ 因为2520%pre_lcm==0,…
[HDU5909]Tree Cutting(FWT) 题面 vjudge 题目大意: 给你一棵\(n\)个节点的树,每个节点都有一个小于\(m\)的权值 定义一棵子树的权值为所有节点的异或和,问权值为\(0..m-1\)的所有子树的个数 题解 考虑\(dp\) 设\(f[i][j]\)表示以\(i\)为根节点的子树中,异或和为\(j\)的子树的个数 很显然,每次合并就是两个\(dp\)值做\(xor\)卷积 那么直接用\(FWT\)优化就行了 #include<iostream> #inclu…
Tree Cutting 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5909 Description Byteasar has a tree T with n vertices conveniently labeled with 1,2,...,n. Each vertex of the tree has an integer value vi. The value of a non-empty tree T is equal to v1⊕v…
Cutting Tree 题目连接: https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=4922 Description Tree in graph theory refers to any connected graph (of nodes and edges) which has no simple cycle, while…
A. Cutting Banner Time Limit: 1 Sec  Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/538/problem/A Description A large banner with word CODEFORCES was ordered for the 1000-th onsite round of Codeforcesω that takes place on the Miami beach. Un…
Codeforces Round #540 (Div. 3) 题目链接:https://codeforces.com/contest/1118 题目太多啦,解释题意都花很多时间...还有事情要做,就选一些题来写吧. B. Tanya and Candies 题意: 在n个数中任意删去一个,如果这个数被删去后,剩余数的奇数和以及偶数和相等,那么就定义这个数为"好数".现在问这n个数中有多少个“好数”. 题解: 预处理出奇数前缀和.偶数前缀和,删去一个数后所有的奇数位置和 就为前面的奇数和…
题文: 见:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=944(紫书p2001) 题解:区间dp,可以设dp[l][r]表示区间i到j的最小花费,所以 dp[l][r]=min(dp[l][r],DP(l,k)+DP(k,r)+cut[r]-cut[l]);k为一个断点,cut[r]-cut[l]为第一次切的花费,转移也非常显然,不过注…
A过水,不讲 题解 CF1077B [Disturbed People] 这题就是个显而易见的贪心可是我考场上差点没想出来 显然把一户被打扰的人家的右边人家的灯关掉肯定比把左边的灯关掉 从左到右扫一遍,每次如果遇到一户被打扰的人家就ans++,然后把它右边的灯关掉 然后就做完了 # include <bits/stdc++.h> int a[101]; int main() { int n; int ans = 0; scanf("%d", &n); for(int…
打算写一个多项式总结. 虽然自己菜得太真实了. 好像四级标题太小了,下次写博客的时候再考虑一下. 模板 \(FFT\)模板 #include <iostream> #include <cstdio> #include <cstdlib> #include <cstring> #include <cmath> #include <cctype> #include <algorithm> #define rin(i,a,b)…
原题如下: Cutting Game Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 5721   Accepted: 2083 Description Urej loves to play various types of dull games. He usually asks other people to play with him. He says that playing those games can show…
我要举报本次校赛出题人的消极出题!!! 官方题解请戳:http://3.scnuacm2015.sinaapp.com/?p=89(其实就是一堆代码没有题解) A. 树链剖分数据结构板题 题目大意:我没看,看不懂. 基本思路:我不会. 参考代码:找Oyk老师和Czj老师去. B. The background of water problem 题目大意(大写加粗的水题):给定$N$个学生和他们$K$个科目的成绩$S_i$,再给出各科目$K_i$的权重顺序$Q_i$,求排名之后,拥有id为$X$的…
以下代码为了阅读方便,省去以下头文件: #include <iostream> #include <stdio.h> #include <math.h> #include <string.h> #include <time.h> #include <stdlib.h> #include <string> #include <bitset> #include <vector> #include <…
2561: 最小生成树(题解) Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 1628  Solved: 786 传送门:http://www.lydsy.com/JudgeOnline/problem.php?id=2561 Description 给定一个边带正权的连通无向图G=(V,E),其中N=|V|,M=|E|,N个点从1到N依次编号,给定三个正整数u,v,和L (u≠v),假设现在加入一条边权为L的边(u,v),那么需要删掉最少多少条…
Problems     # Name     A Infinite Sequence standard input/output 1 s, 256 MB    x3509 B Restoring Painting standard input/output 1 s, 256 MB    x2519 C Money Transfers standard input/output 1 s, 256 MB    x724 D Tree Construction standard input/outp…
题目链接 提交连接:http://acm-software.hrbust.edu.cn/problemset.php?page=5 1470-1482 只做出来四道比较水的题目,还需要加强中等题的训练. 题解: E666 这个题是让求有多少个子串只含有6.寻找连续的6,然后用n*(n+1)/2求出这一段的子串个数,然后把每一段连续的加起来. 做的时候wa了很多次,原来是在n*(n+1)的地方已经超过int型了,所以需要设置类型为long long. #include <cstdio> #inc…
A.Relic Discovery_hdu5982 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 57    Accepted Submission(s): 49 Problem Description Recently, paleoanthropologists have found historical remains on an…
http://poj.org/problem?id=1399 http://acm.hit.edu.cn/hoj/problem/view?id=1037 题意: 在一个最多200*200的minecraft方块地图上(由很多1*1*1的方块搭起来的地图,最高5000),其中两块分别有高0.5米的激光塔,有一个高0.5米的机器人要从其中一个激光塔走到另一个.要求只能走相邻4个方向,每次不能爬上超过1格或跳下超过3格(咦,好像真的很像minecraft),要求每走到一个格子,机器人站在在这个格子的…
学会了网络流,就经常闲的没事儿刷网络流--于是乎来一发题解. 1. COGS2093 花园的守护之神 题意:给定一个带权无向图,问至少删除多少条边才能使得s-t最短路的长度变长. 用Dijkstra或者SPFA跑出来s-t最短路,然后把最短路DAG上的每条边的容量设为1,跑最小割即可. #include<cstdio> #include<cstring> #include<algorithm> #include<queue> #define INF ((~(…
求方程 \[ \begin{array}\\ \sum_{i=1}^n x_i & \equiv & a_1 \pmod{p} \\ \sum_{i=1}^n x_i^2 & \equiv & a_2 \pmod{p} \\ & \vdots & \\ \sum_{i=1}^n x_i^n & \equiv & a_n \pmod{p}\end{array} \] 的解,或输出"NO". 题解 构造多项式\(\prod_i…
题意请看absi大爷的blog http://absi2011.is-programmer.com/posts/200920.html http://absi2011.is-programmer.com/posts/200822.html DAY1 T1 最优比率树形DP? 跟最优比率生成树很像..二分Σp/Σs(暂定为f 判定过程:每个点得到一个新权值f*p[i]-s[i] 做树形dp,dp[i][j]表示以i为根的子树选j个点能得到的最大权值 dp[root][k]>0则为合法 T2 T3…