hdu 2600 War(贪心)题目不难,比赛的时候还是错了一遍
2014-03-18 15:41
387 查看
1、http://acm.hdu.edu.cn/showproblem.php?pid=2600
2、题目大意:
给出一个区间pq
后边给出n个区间,最后输出没有被覆盖的最大的值
3、题目:
Total Submission(s): 1825 Accepted Submission(s): 668
[align=left]Problem Description[/align]
War is the reciprical and violent application of force between hostile political entities aimed at bringing about a desired political end-state via armed conflict. War is an interaction in which two or more militaries have a
“struggle of wills”. When qualified as a civil war, it is a dispute inherent to a given society, and its nature is in the conflict over modes of governance rather than sovereignty. War is not considered to be the same as mere occupation,murder or genocide
because of the reciprical nature of the violent struggle, and the organized nature of the units involved.
War is also a cultural entity, and its practice is not linked to any single type of political organisation or society. Rather, as discussed by John Keegan in his “History Of Warfare”, war is a universal phenomenon whose form and scope is defined by the
society that wages it.
Today we don't want to talk about war, rather than , I want you to tell me which year there was no war.
[align=left]Input[/align]
For each test case, first input one integer N(1<= N <= 100), then two integers p and q (-6000000 <= p <= q <= 6000000) represent the starting year and the ending year in this case. Followed by N wars.
Each war described as follows:
Ai Bi Ni (A,B is integer, p <= A, B <= q, Ni is a String which is the
ith war's name )
Represent that the ith War took place between year A and year B.
[align=left]Output[/align]
Output one number represent which year there was no war in the range p and q, if there are not only one year, output the maximum year which there was no war. If all the year had war, just output "Badly!".
[align=left]Sample Input[/align]
[align=left]Sample Output[/align]
[align=left]Author[/align]
WhereIsHeroFrom
[align=left]Source[/align]
HDU 1st
“Vegetable-Birds Cup” Programming Open Contest
[align=left]Recommend[/align]
lcy
4、AC代码:
2、题目大意:
给出一个区间pq
后边给出n个区间,最后输出没有被覆盖的最大的值
3、题目:
War
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1825 Accepted Submission(s): 668
[align=left]Problem Description[/align]
War is the reciprical and violent application of force between hostile political entities aimed at bringing about a desired political end-state via armed conflict. War is an interaction in which two or more militaries have a
“struggle of wills”. When qualified as a civil war, it is a dispute inherent to a given society, and its nature is in the conflict over modes of governance rather than sovereignty. War is not considered to be the same as mere occupation,murder or genocide
because of the reciprical nature of the violent struggle, and the organized nature of the units involved.
War is also a cultural entity, and its practice is not linked to any single type of political organisation or society. Rather, as discussed by John Keegan in his “History Of Warfare”, war is a universal phenomenon whose form and scope is defined by the
society that wages it.
Today we don't want to talk about war, rather than , I want you to tell me which year there was no war.
[align=left]Input[/align]
For each test case, first input one integer N(1<= N <= 100), then two integers p and q (-6000000 <= p <= q <= 6000000) represent the starting year and the ending year in this case. Followed by N wars.
Each war described as follows:
Ai Bi Ni (A,B is integer, p <= A, B <= q, Ni is a String which is the
ith war's name )
Represent that the ith War took place between year A and year B.
[align=left]Output[/align]
Output one number represent which year there was no war in the range p and q, if there are not only one year, output the maximum year which there was no war. If all the year had war, just output "Badly!".
[align=left]Sample Input[/align]
3 100 200 100 120 RtWar 110 140 WeWar 141 199 QqWar 1 -600 600 -600 600 Cool War
[align=left]Sample Output[/align]
200 Badly!
[align=left]Author[/align]
WhereIsHeroFrom
[align=left]Source[/align]
HDU 1st
“Vegetable-Birds Cup” Programming Open Contest
[align=left]Recommend[/align]
lcy
4、AC代码:
#include<stdio.h> #include<string.h> #include<algorithm> using namespace std; char s[30]; struct node { int x; int y; }a[105]; int cmp(node a,node b) { return a.x<b.x; } int main() { int n,p,q,b,c; while(scanf("%d",&n)!=EOF) { scanf("%d%d",&p,&q); for(int i=1;i<=n;i++) { scanf("%d%d",&a[i].x,&a[i].y); gets(s); } sort(a+1,a+n+1,cmp); int cnt=-16000000; int m=a[1].y; for(int i=2;i<=n;i++) { if(a[i].x>a[i-1].y+1) { cnt=a[i].x-1; //printf("cnt=%d\n",cnt); } if(a[i].y>m) m=a[i].y; } if(m<q) printf("%d\n",q); else if(cnt!=-16000000) { printf("%d\n",cnt); } else { printf("Badly!\n"); } } return 0; }
相关文章推荐
- POJ 3669 BFS
- fstream的使用方法介绍
- Backbone seajs demo2
- rac 11gR2中 gsd 和 oc4j默认offline的解释
- 智力研究(二)
- 条件表达式 x=<表达式1>?<表达式2>:<表达式3>
- ActivityManager
- Linux下的http服务器 v0.0.0.0.0.0.1
- C++左值与右值
- 10.Redis虚拟内存
- 三阴三阳 表里关系
- 360下清除自动记录密码和用户名
- 9.Redis发布及订阅(pub/sub)
- WordCount运行详解
- 解决debian下开机慢(DHCPDISCOVER on eth0)
- 【2014 Esri开发者大会精彩看点】ArcGIS 10.2.2 Native开发产品新特性【上】
- cvSVM及trainSVM参数详解
- 排序算法:冒泡排序&插入排序
- Java的内存模型与Volatile
- Android中处理崩溃异常