UVA 105 - The Skyline Problem(暴力枚举)
2014-03-04 11:42
393 查看
题目链接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&category=&problem=41&mosmsg=Submission+received+with+ID+13257619
题意:给定一些房子的左高右,求出各个房子高度变化的转折点
思路:直接暴力,记录下每个点的最大高度,然后for一遍输出即可。
代码:
#include <stdio.h>
#include <string.h>
const int N = 10005;
int l, h, r;
int vis
;
int main() {
while (~scanf("%d%d%d", &l, &h, &r)) {
for (int i = l; i < r; i++) {
if (vis[i] < h)
vis[i] = h;
}
}
int bo = 0;
for (int i = 1; i <= 10000; i++) {
if (vis[i] == vis[i - 1]) continue;
if (bo++) printf(" ");
printf("%d %d", i, vis[i]);
}
printf("\n");
return 0;
}
题意:给定一些房子的左高右,求出各个房子高度变化的转折点
思路:直接暴力,记录下每个点的最大高度,然后for一遍输出即可。
代码:
#include <stdio.h>
#include <string.h>
const int N = 10005;
int l, h, r;
int vis
;
int main() {
while (~scanf("%d%d%d", &l, &h, &r)) {
for (int i = l; i < r; i++) {
if (vis[i] < h)
vis[i] = h;
}
}
int bo = 0;
for (int i = 1; i <= 10000; i++) {
if (vis[i] == vis[i - 1]) continue;
if (bo++) printf(" ");
printf("%d %d", i, vis[i]);
}
printf("\n");
return 0;
}
相关文章推荐
- UVa 105|The Skyline Problem|暴力|线段树
- uva 105 - The Skyline Problem(暴力)
- uva 105 - The Skyline Problem
- Uva 105 The Skyline Problem
- uva 105 The Skyline Problem
- UVA, 105 The Skyline Problem
- UVALive Problem 7079 How Many Maos Does the Guanxi Worth(暴力枚举+最短路)——2014ACM/ICPC亚洲区广州站
- UVa 105 - The Skyline Problem(利用判断,在于想法)
- UVA 105 - The Skyline Problem
- UVa 105 - The Skyline Problem
- UVa 105 The Skyline Problem (想法题)
- uva 10245 The Closest Pair Problem_枚举
- uva 131 The Psychic Poker Player(暴力枚举+德州扑克)
- uva 11205 The broken pedometer(暴力枚举+子集生成)
- uva 10245 The Closest Pair Problem_枚举
- uva 10245 - The Closest Pair Problem(暴力剪枝)
- UVa OJ 105 - The Skyline Problem
- The Closest Pair Problem UVA - 10245(暴力)
- UVALive - 7457 Discrete Logarithm Problem 费马小定理+暴力枚举+快速幂
- UVALive 7457 Discrete Logarithm Problem (暴力枚举)