
acm
文章平均质量分 53
2了个q
q731040353
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
hdu 6324. Grab The Tree
题意: 一棵树,n个点,n-1条边。每个点的点权为a[i]。Q先拿任意数量个顶点,前提是拿的顶点中任意两个不相邻。T拿Q剩下的顶点。 再最优策略下他们把拿到的点的异或和谁大?如果Q大输出Q T大输出T 平局输出D 思路: 类似博弈吧。答案只有Q和D。 随便拿总有一大一小或两个相等,每次Q拿两个选择中最大的 或者相等的就行, 那么就是先找相等的情况了。当时想的是所有点异或和为0那必定是...原创 2018-07-31 14:06:21 · 153 阅读 · 0 评论 -
Codeforces 1017 C. The Phone Number
题意:构造一个[1,n]排列,要求次序列 最长严格递增子序列长度+最长严格递减子序列长度 最短 思路: eg n=9 第一次的思路: 2 1 4 3 6 5 8 7 9 -> ans=(n+1)/2=7 但是最优的是 3 2 1 6 5 4 9 8 7 -> ans=6 第二次的思路就是枚举n的因子了 a*b=n 就分成a个块 每个块b个元素递减 还是WA!!!心痛...原创 2018-08-09 12:08:26 · 363 阅读 · 0 评论 -
Codeforces Round #495 (Div. 2) 1004D - Sonya and Matrix
题意:给你n个数 为你是否可以构成一个曼哈顿距离矩阵,如果可以输出n,m 和 0所在的坐标(x,y) 题解: 借鉴https://blog.youkuaiyun.com/FSAHFGSADHSAKNDAS/article/details/80951796 巧妙1:利用i*4来求得 x,第一个cnt[i]不等于i*4的i 就是 x b=n+m-x-y 枚举n,m,已知b和x 求y 然后再判断当前 n ...原创 2018-08-09 13:56:14 · 182 阅读 · 0 评论 -
Codeforces 148E Porcelain (预处理+dp)
E. Porcelain time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output During her tantrums the princess usually smashes some collectable por...原创 2018-07-31 17:08:53 · 188 阅读 · 0 评论 -
PAT 1147 Heaps
7秒钟记忆的我搜了一下后序遍历顺序就是:左右根 1wa到多出的空格上 除了数字之间 其他地方不许有空格噢! #include <cstdio> #include <algorithm> #include <math.h> #include <string.h> #include <vector> #include <io...原创 2018-07-31 20:02:24 · 183 阅读 · 0 评论 -
PAT 1146 Topological Order
拓扑排序 按答案顺序判断入度就可以了 #include <cstdio> #include <algorithm> #include <math.h> #include <string.h> #include <vector> #include <iostream> #define ll long long #define...原创 2018-07-31 20:32:50 · 307 阅读 · 0 评论 -
Codeforces ~ 1003D ~ Coins and Queries(贪心)
题意: 给你n个硬币,每个硬币的大小为ai,ai为2的次幂 你需要买一个价值为b的商品,问能否凑成b,如果可以,输出凑成的最少硬币数量 思路: 按照面值从大到小进行贪心 遇到一个面值ai,选择min( cnt[ai] (可以提供的面值为i的硬币数量) 和 b/ai(当前b需要的最多面值为i的硬币数量)) ans+=min b-=min*ai 用map记录硬币面值次数 #incl...原创 2018-08-09 17:40:01 · 234 阅读 · 0 评论 -
CodeForces 1003E Tree Constructing
题意:构造一个直径为d 每个点的度数不超过k的树 (注意直径必须为d 而不是不大于d) 思路: 先构造一个直径 即1-2 2-3 ... d-d+1 然后放入队列中,每次拿出来一个点,判断这个点是否能再放点( 度数是否满 是否是叶子节点) 而且还要保存每一个点在这个树中的位置 为1就是叶子节点 #include <cstdio> #include <algorithm...原创 2018-08-10 10:38:17 · 172 阅读 · 0 评论 -
Codeforces 998D Roman Digits 打表找规律
题意: 四个罗马数字'I','V','X','L'分别表示1,5,10,50,问用这四个罗马数字组成一个长度为n的串能够表示多少个数字? “XI”和“IX”相等都表示的是11。 思路: n辣么大估计有规律可破 那就打表吧 前14个的答案: 4 10 20 35 56 83 116 155 198 244 292 341 390 4...原创 2018-08-10 11:56:35 · 279 阅读 · 0 评论 -
codeforces 1009 D. Relatively Prime Graph
题意: 构造出一个n个点(编号为1-n) m条边的无向连通图 要求没有自循环边和重边 而且每个边所连的顶点 u v 要求 gcd(u,v)=1 问是否可以构造出这个图,如果可以,输出每个边 思路: 首先欧拉函数判断n个点可以构造 这种图 的最大边数maxm 如果m<=maxm 那就暴力枚举边 #include <cstdio> #include <algo...原创 2018-08-07 10:11:51 · 179 阅读 · 0 评论 -
codeforces 1009 E - Intercity Travelling
题意: 你需要从坐标0开车到坐标n,其中坐标1....n-1可以设置休息站。 当你连续开k站时,每两站间的疲劳值为a1,a2……ak,如果第k站有休息点,那么你可以在此处休息,然后接下来的站点的疲劳值又从a1开始,否则继续为ak+1 求所有休息站情况的疲劳值总和 思路: 也就是求和 sum(a[i] * 消耗a[i]出现的总次数) (i->1,2,3,…n); 我们可以按照这种思...原创 2018-08-07 10:47:07 · 272 阅读 · 1 评论 -
codeforces 86D. Powerful array 莫队算法 模板题
题目大意:给定一个数组,每次询问一个区间[l,r],设cnt[i]为数字i在该区间内的出现次数,求该区间内所有的cnt[i]^2 *i。 打多校碰到的莫队算法 学习了一下 第一个模板题~ #include <cstdio> #include <algorithm> #include <math.h> #include <string.h>...原创 2018-08-02 20:16:34 · 178 阅读 · 0 评论 -
HDU 6333 Problem B. Harvest of Apples(莫队算法 组合数预处理)
Problem B. Harvest of Apples Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others) Total Submission(s): 2203 Accepted Submission(s): 858 Problem Description There...原创 2018-08-03 10:35:57 · 192 阅读 · 0 评论 -
HDU 6335 Problem D. Nothing is Impossible
题意: 就是n个人考试,试卷上有m个题,每个题告诉你正确答案s和错误答案t的数量(都>=1),这n个人很团结,选取最优策略, 保证他们当中一定可以有人答对最多S题 思路: 注意:一定 和 最多 每一题答对的可能性为 s/(s+t)。所以s+t个人就可以答对s题 我们只需要用最少的人数答对这一题 那就是t+1个人,一定可以答对1题 所以每道题需要t+1个人才能答对 ...原创 2018-08-03 10:48:09 · 226 阅读 · 0 评论 -
Codeforces 1000D Yet Another Problem On a Subsequence
题意: 定义一个数列是“好的”:第一个数字a[0]为数列长度+1。 定义一个数列的子序列是“好的”:这个子序列能分割成几个“好的”数列。子序列中的每个元素都必须属于其中一个“好的”数列。 给出一个数列,求“好的”子序列的数目。 注意:是分割成 eg。1 1 2 2 就不能分成1 2, 1 2这样的两个好的数列,因为不是分割形成的 思路: dp[i]是以i开头的“好的”子序列数目 ①d...原创 2018-08-15 10:11:31 · 229 阅读 · 0 评论 -
HDU 6336 Problem E. Matrix from Arrays
题意: for (int i = 0; ; ++i) { for (int j = 0; j <= i; ++j) { M[j][i - j] = A[cursor]; cursor = (cursor + 1) % L; } } 按照题目中给的上述方法可以构造出一个无限矩阵 问给你两个坐标,分别是子矩阵的左上角和左下角,让你求这个子...原创 2018-08-03 15:13:54 · 150 阅读 · 0 评论 -
Codeforces 1005E1 - Median on Segments
题意:给出一个1-n的排列,找出中位数为m的连续序列个数。 思路:刚开始想的是预处理m所在位置 左边或者右边 大于它 和 小于它的 个数的前缀和。但是其实记录差就好。 比如预处理右边的pos<=i<=n 个数差。然后从i=pos开始 到i=1结束,记录[i,pos]的大于和小于之差 每次处理一个i ①ans+=mp[-cnt] (mp是之前预处理的右边之差)( -cnt ...原创 2018-08-08 10:39:51 · 216 阅读 · 0 评论 -
HDU 6319 Problem A. Ascending Rating (单调队列)
Problem A. Ascending Rating Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 524288/524288 K (Java/Others) Total Submission(s): 2933 Accepted Submission(s): 924 Problem Description Bef...原创 2018-07-31 13:41:59 · 135 阅读 · 0 评论 -
Codeforces Round #499 (Div. 2) 1011 D. Rocket
D. Rocket time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output This is an interactive problem. Natasha is going to fly to Mars. Finall...原创 2018-07-27 15:07:10 · 313 阅读 · 0 评论 -
codeforces 747 C. Servers 优先队列
C. Servers time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output There are n servers in a laboratory, each of them can perform tasks. E...原创 2018-07-25 10:11:17 · 292 阅读 · 0 评论 -
PAT 1018. Public Bike Management (30)
链接:https://www.nowcoder.com/questionTerminal/4b20ed271e864f06ab77a984e71c090f 来源:牛客网 There is a public bike service in Hangzhou City which provides great convenience to the tourists from all over the ...原创 2018-07-28 17:15:54 · 181 阅读 · 0 评论 -
[PAT]1087. All Roads Lead to Rome (30)
时间限制 200 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Indeed there are many different tourist routes from our city to Rome. You are supposed to find your clients the route with...原创 2018-07-28 18:51:41 · 330 阅读 · 0 评论 -
codeforces 808 C. Tea Party
C. Tea Party time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Polycarp invited all his friends to the tea party to celebrate the ho...原创 2018-07-26 09:55:41 · 301 阅读 · 0 评论 -
1090. Highest Price in Supply Chain (25)
就是一个树 dfs求得树的最大深度 和处于最大深度的叶子点数 #include <cstdio> #include <algorithm> #include <math.h> #include <string.h> #include <vector> #include <map> #include <iostream...原创 2018-07-28 22:01:45 · 243 阅读 · 0 评论 -
PAT- 1901 Acute Stroke (30) dfs or bfs
题意:三维图 找符合条件的1的数目 条件:如果由1组成的联通快的1的数目>=t 那么这个联通块的所有1都符合条件。 看图就知道如果 前后左右上下有相邻的1:这两个1联通 dfs #include <cstdio> #include <algorithm> #include <math.h> #include <string.h> #in...原创 2018-07-29 09:52:02 · 171 阅读 · 0 评论 -
PAT 1094. The Largest Generation (25) dfs
刷的前四道都可以用dfs搞定还是牛客网的顺序就是按类排的 啊啊 题意: 那就是给你一棵以1为根的树 问哪一层的结点数最多 输出最大结点数和层数 DFS #include <cstdio> #include <algorithm> #include <math.h> #include <string.h> #include <vecto...原创 2018-07-29 10:05:25 · 269 阅读 · 0 评论 -
codeforces 822 C. Hacker, pack your bags!
C. Hacker, pack your bags! time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output It's well known that the best way to distract from som...原创 2018-07-26 11:48:40 · 1226 阅读 · 0 评论 -
codeforces 417 C. Football
C. Football time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output One day, at the "Russian Code Cup" event it was decided to play footba...原创 2018-07-26 13:45:33 · 302 阅读 · 0 评论 -
Codeforces 486D Valid Sets(dfs)
D. Valid Sets time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output As you know, an undirected connected graph with n nodes and n - 1 ed...原创 2018-07-30 11:29:06 · 133 阅读 · 0 评论 -
codeforces 1013E(dp)
题意: n个山,需要分别求出建造1...n/2(向上取整)个房子所需要操作次数 房子所在山的高度必须大于旁边的山 每次一个操作可以可以把一个山降低1个高度,问最少需要多少次操作,然后分别输出 思路: dp[i][j][0]=min(dp[i-1][j][0],dp[i-1][j][1]); dp[i][j][1]=min(dp[i-2][j-1][0]+ templ,dp[i-2][j...原创 2018-08-03 17:41:56 · 241 阅读 · 0 评论 -
Codeforces Round #499 (Div. 2) 1011 A. Stages
A. Stages time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Natasha is going to fly to Mars. She needs to build a rocket, which cons...原创 2018-07-27 09:17:41 · 247 阅读 · 0 评论 -
Codeforces Round #499 (Div. 2) 1101 B. Planning The Expedition
B. Planning The Expedition time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Natasha is planning an expedition to Mars for nn people...原创 2018-07-27 09:24:31 · 298 阅读 · 0 评论 -
Codeforces Round #499 (Div. 2) 1011 C. Fly 二分
C. Fly time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Natasha is going to fly on a rocket to Mars and return to Earth. Also, on t...原创 2018-07-27 09:28:24 · 573 阅读 · 2 评论 -
Codeforces 898 D. Alarm Clock 贪心
D. Alarm Clock time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Every evening Vitalya sets n alarm clocks to wake up tomorrow. Eve...原创 2018-07-27 13:56:02 · 321 阅读 · 0 评论 -
codeforces 1008 D. Pave the Parallelepiped
题目大意: T次询问,每次询问给出一个A,B,C,表示一个A×B×C大小的长方体,如果有一种小长方体(表示为a×b×c)(1≤a≤b≤c)能够铺满整个大长方体,这种小长方体就符合条件(要求小的长方体必须以同样的方向来铺),问你有多少种符合条件的小长方体。 题目分析: 将题意转化一下就是,给你三个数A,B,C,问你从这三个数的因子中能挑选出多少种不同的组合。 第一思路:直接把A,B,C...原创 2018-08-08 10:40:44 · 235 阅读 · 0 评论