War
2014-04-30 22:23
99 查看
A - War
Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u
Submit Status Practice HDU
2600
Description
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.
Input
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:
A i B i N i (A,B is integer, p <= A, B <= q, N i is a String which is the ith war's name )
Represent that the ith War took place between year A and year B.
Output
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!".
Sample Input
Sample Output
Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u
Submit Status Practice HDU
2600
Description
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.
Input
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:
A i B i N i (A,B is integer, p <= A, B <= q, N i is a String which is the ith war's name )
Represent that the ith War took place between year A and year B.
Output
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!".
Sample Input
3 100 200 100 120 RtWar 110 140 WeWar 141 199 QqWar 1 -600 600 -600 600 Cool War
Sample Output
200 Badly! #include <iostream> #include <cstring> #include <string> #include <algorithm> using namespace std; class war { public: int starttime; int endtime; bool vis; }; bool cmp(war a,war b) { if(a.endtime!=b.endtime) return b.endtime>a.endtime; else return a.starttime>b.starttime; } war tar[150]; int main() { int testcase; while(cin>>testcase) { memset(tar,0,sizeof(tar)); string tmp; int res=0; int flag=0; int stp,edp; cin>>stp>>edp; for(int i=0;i<testcase;i++) { cin>>tar[i].starttime>>tar[i].endtime; getline(cin,tmp); tar[i].vis=0; } sort(tar,tar+testcase,cmp); if(tar[0].endtime<edp) { cout<<edp<<endl; continue; } for(int i=0;i<testcase;i++) { if(tar[i].endtime>=res) { if(res>=tar[i].starttime) res=tar[i].starttime; } else { flag=1; break; } } if(flag==1) cout<<res-1<<endl; else cout<<"Badly!"<<endl; } return 0; }
相关文章推荐
- js生成日历
- Common FileUpload组件的使用
- C#设计模式之工厂
- 冲刺第七天
- Oracle数据库LOGGING&NOLOGGING模式概述
- grub 引导流程
- 创建自定义提供程序化工具翻译
- 工作流服务减少内存消耗
- 基于Ansible实现批量管理 推荐
- Shopaholic
- 个人冲刺第七天
- c 函数及指针学习 9
- 禁止在工作流设计器启动持续活动的重新编译
- spring mvc执行序列图实例
- hdu 1003 MAX SUM(最大连续子序列和)
- Java之字符串
- 设计流程 工作流
- 一个千兆电口和自协商的问题
- acegi security实践教程—访问系统中资源前必须登陆系统
- Optimal Parking