#include<stdio.h>
#include<string.h>
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<ctype.h>
#include<stack>
#include<math.h>
#include <string>
#include<algorithm>
using namespace std;
typedef unsigned long long ULL;
int main()
{
ios::sync_with_stdio(false);cin.tie(0);
map<string,double> m;
m["UTC"]=0;
m["GMT"]=0;
m["BST"]=1;
m["IST"]=1;
m["WET"]=0;
m["WEST"]=1;
m["CET"]=1;
m["CEST"]=2;
m["EET"]=2;
m["EEST"]=3;
m["MSK"]=3;
m["MSD"]=4;
m["AST"]=-4;
m["ADT"]=-3;
m["NST"]=-3.5;
m["NDT"]=-2.5;
m["EST"]=-5;
m["EDT"]=-4;
m["CST"]=-6;
m["CDT"]=-5;
m["MST"]=-7;
m["MDT"]=-6;
m["PST"]=-8;
m["PDT"]=-7;
m["HST"]=-10;
m["AKST"]=-9;
m["AKDT"]=-8;
m["AEST"]=10;
m["AEDT"]=11;
m["ACST"]=9.5;
m["ACDT"]=10.5;
m["AWST"]=8;
int n;
string times,ap,one,two;
int time,mint;
int sumtime;
cin>>n;
while(n--)
{
time=mint=0;
cin>>times;
if(isdigit(times[0]))
{
int i=0;
while(times[i]!=':')
{
time=time*10+(times[i]-'0');
i++;
}
i++;
while(i<times.size())
{
mint=mint*10+(times[i]-'0');
i++;
}
cin>>ap;
if(ap[0]=='a')
sumtime=(time%12)*60+mint;
else
sumtime=(time%12)*60+mint+12*60;
}
else
if(times=="noon")
sumtime=12*60;
else
sumtime=0;
int sumtime2;
cin>>one>>two;
sumtime2=sumtime-(int)(m[one]*60)+(int)(m[two]*60);
time=(sumtime2+24*60)%(24*60);
if(time==0)
cout<<"midnight"<<endl;
else if(time==12*60)
cout<<"noon"<<endl;
else
{
if(time>12*60)
{
printf("%d:%02d ",(int)(time/60)%12==0?12:(time/60)%12,time%60);
cout<<"p.m."<<endl;
}
else
{
printf("%d:%02d ",(int)(time/60)%12==0?12:(time/60)%12,time%60);
cout<<"a.m."<<endl;
}
}
}
return 0;
}
UVA 10371 POJ 2351 ZOJ 1916 Time Zone(模拟)
最新推荐文章于 2018-12-31 23:22:47 发布