The World(水题)
judge:HDUOJ 6556
source:2018CCPC吉林赛区(重现赛)- 感谢北华大学
Time Limit: 2000/1000 MS (Java/Others)
Memory Limit: 262144/262144 K (Java/Others)
Total Submission(s): 1106
Accepted Submission(s): 378
Problem Description
The World can indicate world travel, particularly on a large scale. You may be lucky enough to be embarking on a six-month overseas trip, or are working, studying or living overseas for an extended period of time. Similarly, this card reinforces Universal understanding and global awareness, and you will have a new appreciation for people and cultures from across the world.
Across the world there are various time zones, leading to time differences. Here you are informed of several famous capitals and their corresponding time zones.
-
Beijing - China - UTC + 8 (China Standard Time)
-
Washington - United States - UTC - 5 (Eastern Standard Time)
-
London - United Kingdom - UTC (Greenwich Mean Time)
-
Moscow - Russia - UTC + 3 (Moscow Time)
Given the local time of a city, you are expected to calculate the date and local time of another specific city among the above capitals.
Input
The first line of input contains a single integer
T
≤
1000
T ≤ 1000
T≤1000 indicating the number of testcases.
Each testcase consists of three lines. The first line is in the form of “hour:minute AM/PM
”
(
1
≤
h
o
u
r
≤
12
,
00
≤
m
i
n
u
t
e
≤
59
)
(1 ≤ hour ≤ 12, 00 ≤ minute ≤ 59)
(1≤hour≤12,00≤minute≤59) indicating the local time. Next two lines contain two strings
s
1
,
s
2
s_1, s_2
s1,s2.
s
1
s_1
s1 is the name of city corresponding to the given time, while
s
2
s_2
s2 indicates the city you are expected to calculate the local time.
Output
For each testcase, begin with “Case i:
”, where i indicate the case number, and then output a single line in the following format“Yesterday/Today/Tomorrow hour:minute AM/PM
”, separated by spaces. The first word describes the corresponding date.
Sample Input
2
12:00 AM
London
Moscow
4:00 PM
London
Beijing
Sample Output
Case 1: Today 3:00 AM
Case 2: Tomorrow 12:00 AM
代码
#include <bits/stdc++.h>
#define LL long long
using namespace std;
int main()
{
map<string, int> mp;
string str = "Beijing"; mp[str] = 8;
str = "Washington"; mp[str] = -5;
str = "London"; mp[str] = 0;
str = "Moscow"; mp[str] = 3;
int T, cas = 1;
cin >> T;
while (T--) {
int cl, mi;
char ap[5];
scanf("%d:%d %s", &cl, &mi, ap);
//AM && 12:**
if (ap[0] == 'A' && cl == 12) {
cl = 0;
}
if (ap[0] == 'P' && cl != 12) cl += 12;
string beg, end;
cin >> beg >> end;
int tim = mp[end] - mp[beg];
cl += tim;
//cout << cl << " " << mi << "\n";
string day = "Today";
ap[0] = 'A';
//check day
if (cl >= 24) {
day = "Tomorrow";
cl -= 24;
}
if (cl < 0) {
cl += 24;
day = "Yesterday";
}
//check A or P
if (cl > 12) {
cl -= 12;
ap[0] = 'P';
}
else if (cl == 12) {
ap[0] = 'P';
}
else if (cl == 0) {
cl = 12;
}
printf("Case %d: ", cas++);
cout << day;
printf(" %d:%02d %s\n", cl, mi, ap);
}
return 0;
}
/*
100
12:00 AM
London
Moscow
4:00 PM
London
Beijing
*/