您的位置:首页 > 其它

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

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;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: