HDU 3700 Cat, hdu3700cat

Source: Internet
Author: User

HDU 3700 Cat, hdu3700cat
CatTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission (s): 451 Accepted Submission (s): 100
Special Judge

Problem DescriptionThere is a cat, cat likes to sleep.
If he sleeps, he sleeps continuously no less than A hours.
For some strange reason, the cat can not stay awake continuously more than B hours.
The cat is lazy, it cocould sleep all the time,
But sometimes interesting events occur (such as cat food, TV show, etc ).
The cat loves these events very much.
So, Please help the cat plan their day so as not to miss any interesting events.
Every day the cat wants to live on the same schedule.
 
InputThe first line of the input file contains two integers A and B (1 <= A, B <= 24 ).
The second line of the input file contains the number n, the number of interesting events (1 <= n <= 20 ).
Following n rows describe the interesting events.
Each event is described line of the form hh: mm-hh: mm, which specifies
The time period during which it occurs. Time varies from 00:00 to 23:59.
No two interesting events will overlap.
If the event is completed earlier than the beginning, This means that it captures midnight.
The event is considered to be occupying the whole minute,
When it begins and the moment when it ends (event-lasted exactly 120 minutes). Start time and time end of the event are different.
 
OutputIf the cat can organize their day so that during all the interesting events not sleep, print to output file Yes.

On the second line Bring k-how many times a day cat shoshould go to bed.
In the following k rows Bring out the intervals in which the cat sleeps in the same format, in which interesting events are set in the input file. If making a few, display any.

If the cat can not organize their day desired way, print to the output file No.
 
Sample Input

12 12123:00-01:003 4307:00-08:0011:00-11:0919:00-19:59
 
Sample Output
Yes101: 07-22: 13NoThere are a lot of details, and the game gets stuck in the game. It's really touching, not to mention
#include <iostream>#include <cstdio>#include <cstring>#include <string>#include <algorithm>#include <set>#include <map>#include <list>#include <queue>#include <stack>#include <deque>#include <vector>#include <bitset>#include <cmath>#include <utility>#define Maxn 100005#define Maxm 1000005#define Inf (1LL<<62)#define inf 0x3f3f3f3f#define eps 1e-8#define lowbit(x) x&(-x)#define lson l,m,rt<<1#define rson m+1,r,rt<<1|1#define PI acos(-1.0)#define make_pair MP#define LL long long #define re freopen("in.txt","r",stdin)#define wr freopen("out.txt","w",stdout)using namespace std;struct Node{    int st,ed,t;    bool friend operator <(Node a,Node b)    {        return a.st<b.st;    }}time[25],ans[25];int main(){    int a,b,n,h1,h2,m1,m2,k,Max;    bool flag;    //re;wr;    while(~scanf("%d%d%d",&a,&b,&n))    {        Max=0;        k=0;        flag=true;        memset(ans,0,sizeof(ans));        for(int i=0;i<n;i++)        {            scanf("%02d:%02d-%02d:%02d",&h1,&m1,&h2,&m2);            time[i].st=h1*60+m1;time[i].ed=h2*60+m2;            if(time[i].ed<time[i].st)                time[i].ed+=1440;            time[i].t=time[i].ed-time[i].st+1;            Max=max(Max,time[i].t);        }        if(Max>b*60)        {            puts("No");            continue;        }        int tt=1440-time[0].t;        if(n==1)        {            if(tt>=a*60)            {                puts("Yes");                puts("1");                int hh1=((time[0].ed+1)/60)%24;                int mm1=(time[0].ed+1)%60;                int hh2=time[0].st-1>=0?((time[0].st-1)/60)%24:23;                int mm2=((time[0].st-1)+60)%60;                printf("%02d:%02d-%02d:%02d\n",hh1,mm1,hh2,mm2);            }            else                puts("No");            continue;        }        sort(time,time+n);        tt=time[0].st+1440-time[n-1].ed-1;        int tmp;        if(tt>=a*60)        tmp=0;        else        {        tmp=tt+time[n-1].t;        int p=n-1;        while(p>=1&&time[p].st-time[p-1].ed-1<a*60)        {        tmp+=time[p].st-time[p-1].ed-1+time[p-1].t;        p--;        }        }        for(int i=0;i<n;i++)        {            tmp+=time[i].t;            if(tmp>b*60)            {                flag=false;                break;            }            if(i!=n-1)            {            if(time[i+1].st-time[i].ed-1>=a*60)            {                ans[++k].st=time[i].ed+1;                ans[k].ed=time[i+1].st-1;                tmp=0;            }            else                 tmp+=time[i+1].st-1-time[i].ed;               if(tmp>b*60)            {                flag=false;                break;            }            }                }        if(tt>=a*60)        {            k++;            ans[k].st=time[n-1].ed+1;ans[k].ed=time[0].st-1;        }        if(flag&&k)        {            puts("Yes");            printf("%d\n",k);            for(int i=1;i<=k;i++)            {                int hh1=(ans[i].st/60)%24;                int mm1=(ans[i].st+60)%60;                int hh2=ans[i].ed>=0?(ans[i].ed/60)%24:23;                int mm2=(ans[i].ed+60)%60;                printf("%02d:%02d-%02d:%02d\n",hh1,mm1,hh2,mm2);            }        }        else            puts("No");    }    return 0;}



HDU 1012 1070 1157 1009 2564 forgot to point out the error and would like to thank you for not downgrading the code.

The landlord, if no one answers this question, please send it to me. Thank you! It's a waste of resources !~
O (partition _ partition) o...
 
Hdu 1583 dna assembly

The Code goes straight up.
////////////////////////////
// Title: hdu 1583 dna assembly
// Code by: bind bluebird
// The program is compiled and qualified under Windows 7 VC6.0.
//////////////////////////////
# Include <stdio. h>
# Include <string. h>
# Include <memory. h>
Int dna com (char * DNA _a, char * DNA _ B) // used to verify the number of common bases for two DNA Fragments
{
Int DNA _offset = 0;
While (* (DNA _a + DNA _offset ))
{
If (* (DNA _a + DNA _offset) = * (DNA _ B + DNA _offset ))
{
DNA _offset ++;
}
Else
{
DNA _ A ++;
DNA _offset = 0;
}
}
Return DNA _offset;
}
Int getdna commax (char * DNA _a, char * DNA _ B)
{
Int n1 = dna com (DNA _ A, DNA _ B );
Int n2 = dna com (DNA _ B, DNA _a );
Return n1> n2? N1: n2;
}
Bool legDNA (char * DestDNA) // judge the legitimacy of the DNA. Although not mentioned in the question, it is still well written.
{
While (* (DestDNA ))
{
If (* DestDNA! = 'A' & * DestDNA! = 'G' & * DestDNA! = 'C' & * DestDNA! = 'T ')
Return false;
DestDNA ++;
}
Return true;
}
Void mergedDNA (char * DNA _a, char * DNA _ B) // connects two DNA fragments.
{
Char DNA _ Buf [1024];
Memset (DNA_Buf, 0, sizeof (DNA_Buf ));
Int Com1 = dna com (DNA _ A, DNA _ B );
Int Com2 = dna com (DNA _ B, DNA _ );
If (Com1> Com2)
{
Strcpy (DNA _buf, DNA _a );
Strcat (DNA _buf, DNA _ B + Com1 );
}
Else
{
Strcpy (DNA _buf, DNA _ B );
Strcat (DNA _buf, DNA _a + Com2 );
}
Strcpy (DNA _a, DNA _bu... the remaining full text>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.