Title Description
Because time had rained, it is important along with precipitation. Now, there is 1 of a day, because the notes were found on the time it was raining, to organize this, I would like to examine the time that had rained.
Organize, proceed according to the following rules.
- From the note-sensitive rain time, the day 1 issues a time that had rained the day in chronological order. Rain is falling beyond the date, 00:00 0 0 : 0 0 down began and 24:00 2 4 : 0 and 0 shall be treated as end down, memo, such as to straddle the date is not input.
- Each end down, it started to fall of rain immediately before and immediately after 5 rounds at a time of 5 minutes. For example, 13:23 1 3 : 2 3 in the beginning to get down 14:01 1 4 : 0 rain ceased to 1, 13:20 1 3 : 2 0 from 14:05 1 4 : 0 5 that was falling to to.
-
In results after rounding, 2 if Kan'ame time was written into two or more notes have been duplicated, 1 regarded as one continuous rain. For example, 11:06 1 1 : 0 6 to beginning to get off 11:23 1 1 : 2 3 in the rain ceased, 11:29 1 1 : 2 9 to get off began with 12:03 1 2 : 0 rain ceased to 3, 11:48 1 1 : 4 8 to get off starting to 12:10 1 2 : 1 0 in the rain ceased 3 If you are three there, 11:05 1 1 : 0 5 ~ 11:251 1 : 2 5, 11:25 1 1 : 2 5 ~ 12:05 1 2 : 0 5, 11:45 1 1 : 4 5 ~ 12:10 1 2 : 1 0 3 is a three rain, and stuck a place where time is wearing 11:05 1 1 : 0 5 from 12:10 1 2 : 1 was falling to 0, 1 will be referred to one of continuous rain.
When the contents of the memo is input, the time that had rained, please create a program that outputs to organize to meet this rule.
Input and output formats
Input formats:
Output formats:
To organize the time when it was raining, down to the early order of time at the beginning, you should output the time of the end down the time that began to fall, separated by a hyphen.
At that time, continuous 1 one rain 1 outputs on one line, the time format using the same format as the input.
In addition, putting a line break at the end of the output.
Problem-solving ideas
The first step is certainly to go to the translation, the rest of the solution to a problem Satomi (the only one submitted by Los valley, so lonely).
answer
1 #include<bits/stdc++.h> 2 using namespace std; 3 string sj[1000001]; 4 int main() 5 { 6 int n; 7 string s; 8 string x,y,x1,y1; 9 scanf("%d",&n); 10 for(int i=1;i<=n;i++) 11 { 12 cin>>s; 13 if(s[3]>='1'&&s[3]<='4')s[3]='0';//舍去 14 else if(s[3]>='6'&&s[3]<='9')s[3]='5';//舍去 15 if(s[8]>='1'&&s[8]<='4')s[8 ] = ' 5 ' ; // to large about 16 the else IF (S [ 8 ]> = ' . 6 ' && S [ 8 ] <= ' . 9 ' ) // the large about the carry . 17 { 18 is S [ 8 ] = ' 0 ' ; . 19 IF (S [ . 7 ] == ' . 5 ' ) // min offer 20 is { 21 is S [ . 7 ] = '0'; 22 if(s[6]=='9')//进位 23 { 24 s[6]='0'; 25 s[5]++; 26 } 27 else s[6]++; 28 } 29 else s[7]++; 30 } 31 sj[i]=s; 32 } 33 sort(sj+1,sj+1+n); 34 x=sj[1].substr(0,4); 35 y=sj[1].substr(5,4); 36 for(int i=2;i<=n;i++) 37 { 38 x1=sj[i].substr(0,4); 39 y1=sj[i].substr(5,4); 40 if(x1>=x&&x1<=y&&y1>=y){sj[i]=x+'-'+y1;x=x;y=y1;continue;} 41 else if(x1>=x&&x1<=y&&y1>=x&&y1<=y){sj[i]=x+'-'+y;continue;}//各种判断,理解靠自己 42 else{ 43 x=x1; 44 y=y1; 45 cout<<sj[i-1]<<endl; 46 } 47 } 48 cout<<sj[n]<<endl; 49 return 0; 50 }