自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(37)
  • 收藏
  • 关注

原创 洛谷 P1583 魔法照片

#include<bits/stdc++.h>using namespace std;const int N=111111;int e[N];struct node{ int w,id;}q[N];bool cmp(node a,node b){ if(a.w==b.w) return a.id<b.id; else return a.w...

2019-03-16 19:03:06 165

原创 洛谷 1571 眼红的Medusa

#include<bits/stdc++.h>using namespace std;map<int,bool> v;int a[111111],b[111111];int n,m;bool work(int k){ int l,r,mid; l=1;r=m; while(l<=r) { mid=(l+r)...

2019-03-16 18:41:53 380

原创 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 182

原创 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 192

原创 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 133

原创 Codeforces ~ 1003D ~ Coins and Queries(贪心)

题意:给你n个硬币,每个硬币的大小为ai,ai为2的次幂你需要买一个价值为b的商品,问能否凑成b,如果可以,输出凑成的最少硬币数量思路:按照面值从大到小进行贪心遇到一个面值ai,选择min( cnt[ai] (可以提供的面值为i的硬币数量) 和 b/ai(当前b需要的最多面值为i的硬币数量))ans+=minb-=min*ai用map记录硬币面值次数#incl...

2018-08-09 17:40:01 167

原创 Codeforces Round #495 (Div. 2) 1004D - Sonya and Matrix

题意:给你n个数 为你是否可以构成一个曼哈顿距离矩阵,如果可以输出n,m 和 0所在的坐标(x,y)题解:借鉴https://blog.csdn.net/FSAHFGSADHSAKNDAS/article/details/80951796巧妙1:利用i*4来求得 x,第一个cnt[i]不等于i*4的i 就是 xb=n+m-x-y 枚举n,m,已知b和x 求y然后再判断当前 n ...

2018-08-09 13:56:14 134

原创 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 301

原创 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 187

原创 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 152

原创 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 198 1

原创 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 139

原创 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 180

原创 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 97

原创 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 153

原创 HDU 6333 Problem B. Harvest of Apples(莫队算法 组合数预处理)

Problem B. Harvest of ApplesTime Limit: 4000/2000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 2203    Accepted Submission(s): 858Problem DescriptionThere...

2018-08-03 10:35:57 130

原创 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 129

原创 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 248

原创 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 121

原创 Codeforces 148E Porcelain (预处理+dp)

E. Porcelaintime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputDuring her tantrums the princess usually smashes some collectable por...

2018-07-31 17:08:53 127

原创 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 110

原创 HDU 6319 Problem A. Ascending Rating (单调队列)

Problem A. Ascending RatingTime Limit: 10000/5000 MS (Java/Others)    Memory Limit: 524288/524288 K (Java/Others)Total Submission(s): 2933    Accepted Submission(s): 924 Problem DescriptionBef...

2018-07-31 13:41:59 91

原创 Codeforces 486D Valid Sets(dfs)

D. Valid Setstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputAs you know, an undirected connected graph with n nodes and n - 1 ed...

2018-07-30 11:29:06 100

原创 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 202

原创 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 132

原创 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 165

原创 [PAT]1087. All Roads Lead to Rome (30)

时间限制200 ms内存限制65536 kB代码长度限制16000 B判题程序Standard作者CHEN, YueIndeed 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 229

原创 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 130

原创 Codeforces Round #499 (Div. 2) 1011 D. Rocket

D. Rockettime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThis is an interactive problem.Natasha is going to fly to Mars. Finall...

2018-07-27 15:07:10 254

原创 Codeforces 898 D. Alarm Clock 贪心

D. Alarm Clocktime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputEvery evening Vitalya sets n alarm clocks to wake up tomorrow. Eve...

2018-07-27 13:56:02 261

原创 Codeforces Round #499 (Div. 2) 1011 C. Fly 二分

C. Flytime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputNatasha is going to fly on a rocket to Mars and return to Earth. Also, on t...

2018-07-27 09:28:24 441 2

原创 Codeforces Round #499 (Div. 2) 1101 B. Planning The Expedition

B. Planning The Expeditiontime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputNatasha is planning an expedition to Mars for nn people...

2018-07-27 09:24:31 224

原创 Codeforces Round #499 (Div. 2) 1011 A. Stages

A. Stagestime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputNatasha is going to fly to Mars. She needs to build a rocket, which cons...

2018-07-27 09:17:41 178

原创 codeforces 417 C. Football

C. Footballtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputOne day, at the "Russian Code Cup" event it was decided to play footba...

2018-07-26 13:45:33 244

原创 codeforces 822 C. Hacker, pack your bags!

C. Hacker, pack your bags!time limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputIt's well known that the best way to distract from som...

2018-07-26 11:48:40 644

原创 codeforces 808 C. Tea Party

C. Tea Partytime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputPolycarp invited all his friends to the tea party to celebrate the ho...

2018-07-26 09:55:41 203

原创 codeforces 747 C. Servers 优先队列

C. Serverstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere are n servers in a laboratory, each of them can perform tasks. E...

2018-07-25 10:11:17 245

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除