HDOJ City hall 1453(模拟)
来源:互联网 发布:淘宝在线店招制作 编辑:程序博客网 时间:2024/05/16 23:45
City hall
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 256 Accepted Submission(s): 160
Problem Description
Because of its age, the City Hall has suffered damage to one of its walls. A matrix with M rows and N columns represents the encoded image of that wall, where 1 represents an intact wall and 0 represents a damaged wall (like in Figure-1).
1110000111
1100001111
1000000011
1111101111
1110000111
Figure-1
To repair the wall, the workers will place some blocks vertically into the damaged area. They can use blocks with a fixed width of 1 and different heights of {1,2, ..., M}.
For a given image of the City Hallˇs wall, your task is to determine how many blocks of different heights are needed to fill in the damaged area of the wall, and to use the least amount of blocks.
1110000111
1100001111
1000000011
1111101111
1110000111
Figure-1
To repair the wall, the workers will place some blocks vertically into the damaged area. They can use blocks with a fixed width of 1 and different heights of {1,2, ..., M}.
For a given image of the City Hallˇs wall, your task is to determine how many blocks of different heights are needed to fill in the damaged area of the wall, and to use the least amount of blocks.
Input
There is only one test case. The case starts with a line containing two integers M and N (1 <= M, N <= 200). Each of the following M lines contains a string with length of N, which consists of ¨1〃s and/or ¨0〃s. These M lines represent the wall.
Output
You should output how many blocks of different heights are needed. Use separate lines of the following format:
k Ck
where k劇{1,2, ..., M} means the height of the block, and Ck means the amount of blocks of height k that are needed. You should not output the lines where Ck = 0. The order of lines is in the ascending order of k.
k Ck
where k劇{1,2, ..., M} means the height of the block, and Ck means the amount of blocks of height k that are needed. You should not output the lines where Ck = 0. The order of lines is in the ascending order of k.
Sample Input
5 1011100001111100001111100000001111111011111110000111
Sample Output
1 72 13 25 1
Source
ACM暑期集训队练习赛(七)
Recommend
lcy | We have carefully selected several similar problems for you: 1415 1981 1455 1452 1430
#include<stdio.h>#include<string.h>#include<algorithm>#define INF 0x3f3f3f3fusing namespace std;int main(){double l;while(scanf("%lf",&l)!=EOF){int n;double c,t;double dp[110];double p[110];memset(p,0,sizeof(p));memset(dp,0,sizeof(dp));scanf("%d%lf%lf",&n,&c,&t);double vr,v1,v2;scanf("%lf%lf%lf",&vr,&v1,&v2);for(int i=1;i<=n;i++)scanf("%lf",&p[i]);p[0]=0;p[n+1]=l;double T1=l/vr,time;dp[0]=0;for(int i=1;i<=n+1;i++){dp[i]=INF;for(int j=0;j<i;j++){double S=p[i]-p[j];if(S>c)time=(c/v1)+(S-c)/v2;else time=S/v1;if(j!=0)time+=t;dp[i]=min(dp[i],dp[j]+time);}}if(T1>dp[n+1])printf("What a pity rabbit!\n");elseprintf("Good job,rabbit!\n");}return 0;}
0 0
- HDOJ City hall 1453(模拟)
- City hall
- City hall
- Monty Hall问题 模拟
- HDOJ 4496 D-City
- HDOJ 1505 City Game
- NOI模拟:保镖(Hall定理)
- City -hdoj 4496-并查集删边
- HDOJ 5533 Dancing Stars on Me(凸包,convex hall)
- uva 1330 - City Game 模拟
- jzoj 5000. 【NOI2017模拟3.4】保镖 hall定理+搜索
- Monty Hall(娱乐节目抽奖游戏)蒙特卡洛模拟:
- HDU/HDOJ----4252 A Famous City
- HDOJ 4252 A Famous City 单调栈
- hdoj 1506&&1505(City Game) dp
- Hdoj 4496 D-City 【并查集】
- HDOJ 5352 MZL's City 匈牙利匹配
- 【费用流】 HDOJ 5352 MZL's City
- CADisplayLink结合UIBezierPath的神奇妙用
- Android软件设置自动检查更新
- STM32F10xx 通过 FSMC 与 ILI93xxTFTLCD驱动的通信的若干问题
- 【转载】J2SE知识点归纳笔记(七)---Java IO Part 1:File类与RandomAccessFile类
- javascript实现基于类的继承
- HDOJ City hall 1453(模拟)
- HDU1312 Red and Black
- 社保基金一季度新进多只“一带一路”
- eclipse背景设置什么颜色缓解眼睛疲劳之一
- POJ_3321_Apple tree_dfs,树状数组
- KVC 与 KVO 理解
- 系统分析师笔记--面向对象方法学
- 前端web
- 使iframe高度和宽度适应浏览器可视区域大小