博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
HDU 2600 War(水题 区间边排序+贪心)
阅读量:4139 次
发布时间:2019-05-25

本文共 2421 字,大约阅读时间需要 8 分钟。

War

Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 2340 Accepted Submission(s): 818
Problem 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
3100 200100 120 RtWar110 140 WeWar141 199 QqWar 1-600 600-600 600 Cool War
Sample Output
200Badly!  
//注意战争名含有空格的字符串 一直wa
#include 
#include
#include
#include
#include
#include
#include
using namespace std;struct Range{ int a,b;}r[100+10];bool cmp(Range x,Range y){ if(x.b!=y.b) return x.b>y.b; else return x.a>=y.a;}int main(){ int t,p,q,i; string s; while(scanf("%d",&t)==1){ scanf("%d%d",&p,&q); for(i=0;i
r[i].b) swap(r[i].a,r[i].b); } sort(r,r+t,cmp); for(i=0;i
r[i].b) break; else q=min(q,r[i].a-1); } if(q>=p) printf("%d\n",q); else printf("Badly!\n"); } return 0;}

转载地址:http://lymvi.baihongyu.com/

你可能感兴趣的文章
HTML 5 新的表单元素 datalist keygen output
查看>>
(转载)正确理解cookie和session机制原理
查看>>
jQuery ajax - ajax() 方法
查看>>
将有序数组转换为平衡二叉搜索树
查看>>
最长递增子序列
查看>>
从一列数中筛除尽可能少的数,使得从左往右看这些数是从小到大再从大到小...
查看>>
判断一个整数是否是回文数
查看>>
经典shell面试题整理
查看>>
腾讯的一道面试题—不用除法求数字乘积
查看>>
素数算法
查看>>
java多线程环境单例模式实现详解
查看>>
将一个数插入到有序的数列中,插入后的数列仍然有序
查看>>
在有序的数列中查找某数,若该数在此数列中,则输出它所在的位置,否则输出no found
查看>>
万年历
查看>>
作为码农你希望面试官当场指出你错误么?有面试官这样遭到投诉!
查看>>
好多程序员都认为写ppt是很虚的技能,可事实真的是这样么?
查看>>
如果按照代码行数发薪水会怎样?码农:我能刷到公司破产!
查看>>
程序员失误造成服务停用3小时,只得到半月辞退补偿,发帖喊冤
查看>>
码农:很多人称我“技术”,感觉这是不尊重!纠正无果后果断辞职
查看>>
php程序员看过来,这老外是在吐糟你吗?看看你中了几点!
查看>>