hdu 4252 A Famous City】的更多相关文章

题意:一张相片上的很多建筑相互遮住了,根据高低不同就在相片上把一座高楼的可见部分作为一个矩形,并用数字描述其高度,若一张相片上的两个建筑群中间有空地,高度则为0;求最少有多少个建筑; 分析: 输入的0不是建筑,则输入的总个数减去0的个数就是最多可能有的建筑数;再从第一个开始从前往后搜,若发现比它高的则继续搜,若发现比它低的则说明它是一个独立的建筑,这时可以返回搜其它的;若与它相等,说明这时它们还没有出现比它们低的建筑,则视其为同一个建筑,则ans减1; #include<cstdio> #in…
单调栈: 维护一个单调栈 A Famous City Time Limit: 10000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1671    Accepted Submission(s): 644 Problem Description After Mr. B arrived in Warsaw, he was shocked by the skyscrap…
题目链接: Hdu 5352 MZL's City 题目描述: 有n各节点,m个操作.刚开始的时候节点都是相互独立的,一共有三种操作: 1:把所有和x在一个连通块内的未重建过的点全部重建. 2:建立一条双向路(x,y) 3:又发生了地震,p条路被毁. 问最后最多有多少个节点被重建,输出重建节点的最小字典序. 解题思路: 这几天正好在学匹配,但是昨天下午还是没有看出来这个是匹配题目.看了题解扪心自问了自己三次,是不是傻.就是把每个需要重建的节点x拆成k个点,然后对每个拆分后的点和与拆点在同一连通块…
HDU 4849 Wow! Such City! 题目链接 题意:依照题目中的公式构造出临接矩阵后.求出1到2 - n最短路%M的最小值 思路:就依据题目中方法构造矩阵,然后写一个dijkstra,利用d数组取求答案就可以 代码: #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> using namespace std; const long long…
最后更新于2019.1.23 A Famous City ?戳这里可以前往原题 Problem Description After Mr. B arrived in Warsaw, he was shocked by the skyscrapers and took several photos. But now when he looks at these photos, he finds in surprise that he isn't able to point out even the…
题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=4255 A Famous Grid Description Mr. B has recently discovered the grid named "spiral grid".Construct the grid like the following figure. (The grid is actually infinite. The figure is only a small par…
The Famous Clock Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1399    Accepted Submission(s): 940 Problem Description Mr. B, Mr. G and Mr. M are now in Warsaw, Poland, for the 2012's ACM-ICPC…
Two Famous Companies Time Limit: 15000ms Memory Limit: 32768KB This problem will be judged on HDU. Original ID: 425364-bit integer IO format: %I64d      Java class name: Main   In China, there are two companies offering the Internet service for the p…
The Famous ICPC Team Again Problem Description   When Mr. B, Mr. G and Mr. M were preparing for the 2012 ACM-ICPC World Final Contest, Mr. B had collected a large set of contest problems for their daily training. When they decided to take training, M…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4249 题目大意:给一个a+b=c的表达式,但是a.b.c中部分位的数字丢失,并用?代替,问有多少种方案使得这个表达式成立. Sample Input 7+1?=1? ?1+?1=22   Sample Output Case 1: 3 Case 2: 1   Hint There are three solutions for the first case: 7+10=17, 7+11=18, 7+…
最大01子矩阵和,就是一个矩阵的元素不是0就是1,然后求最大的子矩阵,子矩阵里的元素都是相同的. 这个题目,三个oj有不同的要求,hoj的要求是5s,poj是3秒,hdu是1秒.不同的要求就对应不同的难度,不同的逼格. 先看最low的, HOJ 1664 5秒钟的时间,够长了.我很容易想到可以最大子矩阵和来求解,二者本来就很像,关于最大子矩阵和这个博客里有介绍 最大子矩阵和 这里我们可以把F变成1,把R变成负无穷大,这样求解最大子矩阵和就可以得到答案 #include <iostream> #…
A Famous Stone Collector Time Limit: 30000/15000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 793    Accepted Submission(s): 292 Problem Description Mr. B loves to play with colorful stones. There are n colors of…
MZL's City Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 710    Accepted Submission(s): 245 Problem Description MZL is an active girl who has her own country. Her big country has N cities numb…
The Famous ICPC Team Again Time Limit: 30000/15000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1440    Accepted Submission(s): 708 Problem Description When Mr. B, Mr. G and Mr. M were preparing for the 2012 ACM-I…
The Famous ICPC Team Again Time Limit: 30000/15000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1091    Accepted Submission(s): 530 Problem Description When Mr. B, Mr. G and Mr. M were preparing for the 2012 ACM-I…
MZL's City Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 743    Accepted Submission(s): 260 Problem Description MZL is an active girl who has her own country. Her big country has N cities numb…
A Famous Stone Collector Problem Description Mr. B loves to play with colorful stones. There are n colors of stones in his collection. Two stones with the same color are indistinguishable. Mr. B would like to  select some stones and arrange them in l…
[题意]:给出n个点,m条边,边分为两种,一种是A公司的,一种是B公司的.边上有权值,问用n-1条边把n个点连起来的最小费用是多少,其中A公司的边刚好有k条.题目保证有解. 思路:我们发现,如果我们给白边增加权值,做最小生成树,由于白边权值增大,导致不容易选白边.记f(x)为给白边增加x权值,做最小生成树后,选白边的数量,可以发现,f(x)随x增大而减小.所以可以二分x 首先,直接做MST的话白色边的数量是无法估计的.可能比要求的多,也可能更少 所以考虑怎样调整白色边的数量 通过这个思路,可以想…
首先发现一个很头痛的问题,下面是2个求排列组合的代码 memset(C,,sizeof(C)); ;i<;i++) { C[i][]=; ;j<=;j++) C[i][j]=(C[i-][j]+C[i-][j-])%MOD; } C[][]=; ;i<;i++) ;j<=;j++) ) C[i][j]=C[i-][j]; ][j]+C[i-][j-])%MOD; 其中第一个是刘汝佳上面的代码,不知为什么在杭电OJ上就是WA,第二个就能AC,就路过的大神指点 题目大意 给你一些不同颜…
http://www.bnuoj.com/bnuoj/problem_show.php?pid=25659 #include <iostream> #include <stdio.h> #include <string.h> #include <math.h> #include <algorithm> #include <stack> using namespace std; int main() { ; while(~scanf(&…
Problem Description Mr. B, Mr. G, Mr. M and their coach Professor S are planning their way to Warsaw for the ACM-ICPC World Finals. Each of the four has a square-shaped suitcase with side length Ai (1<=i<=4) respectively. They want to pack their sui…
最小费用最大流,因为要控制字典序,网络流控制不好了...一直WA,所以用了费用流,时间早的费用大,时间晚的费用少. 构图: 建立一个超级源点和超级汇点.超级源点连向1操作,容量为K,费用为COST,然后COST-1,因为下一次遇到1操作,费用为减少1,即COST-1: 每个1操作连向当前能建造的城市,容量为1,费用为0: 每个城市连向汇点,容量为1,费用为0: #include<cstdio> #include<cstring> #include<cmath> #inc…
Time Limit: 15000/8000 MS (Java/Others) Memory Limit: 102400/102400 K (Java/Others)   Input There are several test cases. Please process till EOF.For each test case, there is only one line containing 6 integers N,M,X0,X1,Y0,Y1.See the description for…
题目大意: 一个地方的点和道路在M年前全部被破坏,每年可以有三个操作, 1.把与一个点X一个联通块内的一些点重建,2.连一条边,3.地震震坏一些边,每年最多能重建K个城市,问最多能建多少城市,并输出操作要让字典序最小 思路: trivial:显然每年向当年可以建的城市连边,每年可以匹配最多K个城市,嗯,很明显的网络流思路,可这样方案数不太好输出 full:再仔细想想这就是多对一的多重匹配,跑一跑匈牙利就可以,K个城市可以拆点,当然简单的方法直接跑K次也可以(想一想为什么) 为了字典序最小,我们要…
题目链接:点击打开链接 思路:用d[i][a][b][c][is]表示当前到了第i位, 三个数的i位各自是a,b,c, 是否有进位 , 的方法数. 细节參见代码: #include<cstdio> #include<cstring> #include<algorithm> #include<iostream> #include<string> #include<vector> #include<stack> #includ…
[SinGuLaRiTy] Copyright (c) SinGuLaRiTy 2017.  All Rights Reserved. [CQBZOJ 2011] 计算系数 题目描述 给定一个多项式(ax + by)^k,请求出多项式展开后x^n y^m项的系数. 输入 共一行,包含 5 个整数,分别为a,b,k,n,m,每两个整数之间用一个空格隔开. 输出 输出共 1 行,包含一个整数,表示所求的系数,这个系数可能很大,输出对10007 取模后的结果. 样例数据 样例输入 样例输出 1 1 3…
A Famous City 题目大意 给出正视图  每一列为楼的高度 最少有几座楼 坑点 楼高度可以为0 代表没有楼 贡献了两发RE 原因 if(!s.empty()&&tem){s.push(tem); continue;}并不能筛去 空栈且 tem为0的情况 改为 if(!s.empty()){if(tem) s.push(tem); continue;} 后AC 题目思路 维护一个单调递增的栈  假如新加入的楼高度小于top元素 那我们知道top元素一定是单独的一栋楼 我们就pop掉…
City Planning Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 483    Accepted Submission(s): 203 Problem Description After many years, the buildings in HDU has become very old. It need to rebuil…
City Planning Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 503    Accepted Submission(s): 213 Problem Description After many years, the buildings in HDU has become very old. It need to rebui…
F - City Game Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Status Practice HDU 1505 Appoint description: Description Bob is a strategy game programming specialist. In his new city building game the gaming enviro…