Problem:


時計の短い針と長い針

原始スローライフ主義組織「アカルイダ」から、いたずらの予告状が届きました。アカルイダといえば、要人の顔面にパイを投げつけたりするいたずらで有名ですが、最近では火薬を用いてレセプション会場にネズミ花火をまき散らすなど、より過激化してきました。予告状は次の文面です。

---パソコン ヒトの時間を奪う。良くない。
時計の短い針と長い針 出会うころ、アカルイダ 正義行う。
スローライフ 偉大なり。

たどたどしくてよく解らないのですが、時計の短針と長針とが重なったころにいたずらを決行するという意味のようです。

このいたずらを警戒するため、時刻を入力として、短針と長針が近い場合は "alert"、遠い場合は "safe"、それ以外の場合は "warning" と出力するプログラムを作成してください。ただし、「近い」とは短針と長針の角度が 0° 以上 30° 未満の場合をいい、「遠い」とは 90° 以上 180° 以下の場合をいいます。なお、時刻は 00:00 以上 11:59 以下とします。

Input

入力は以下の形式で与えられます。

n
hh1:mm1
hh2:mm2
:
hhn:mmn

1 行目に判定する時刻の個数 n（1 ≤ n ≤ 10000）、2 行目以降に i 番目の時刻 hhi:mmi  がそれぞれ１行に与えられます。

Output

i 番目の時刻の判定結果 safe、warning、または alert を順番にそれぞれ１行に出力してください。

Sample Input

4
02:15
06:01
11:55
10:40

Output for the Sample Input

alert
safe
alert
warning



Sample input:
4
02:15
06:01
11:55
10:40


Sample output:
alert
safe
alert
warning

Submission status: Wrong Answer

Solution code:

n = input()
for i in range(n):
    h,m = map(int, raw_input().split(":"))
    sangle = 360 * (h * 60 + m) / 720
    langle = 360 * m / 60
    angle = abs(sangle - langle)
    if (0 <= angle < 30):
        print "alert"
    elif (90 <= angle <= 180):
        print "safe"
    else:
        print "warning"

Submission status: Wrong Answer

Solution code:

n = input()
for i in range(n):
    h,m = map(int, raw_input().split(":"))
    sangle = 1.0 * 360 * (h * 60 + m) / 720
    langle = 1.0 * 360 * m / 60
    angle = abs(sangle - langle)
    
    if (0 <= angle < 30):
        print "alert"
    elif (90 <= angle <= 180):
        print "safe"
    else:
        print "warning"

Submission status: Wrong Answer

Solution code:
for _ in range(int(raw_input())):
    h,m = map(int,raw_input().split(":"))
    lng = 30*h+1.0/4.0*m
    short = 6*m
    arg = abs(lng-short)
    if   arg < 30: print "alert"
    elif arg < 90: print "warning"
    else         : print "safe"

Submission status: Wrong Answer

Solution code:
for _ in range(int(raw_input())):
    h,m = map(int,raw_input().split(":"))
    lng = 30*h+1.0/4.0*m
    short = 6*m
    if short > lng: lng,short = short,lng
    arg = lng-short if lng-short < 181 else 180-(lng-short)
    if   arg < 30: print "alert"
    elif arg < 90: print "warning"
    else         : print "safe"

Submission status: Wrong Answer

Solution code:
for _ in range(int(raw_input())):
    h,m = map(int,raw_input().split(":"))
    lng = 30*h+1.0/4.0*m
    short = 6*m
    if short > lng: lng,short = short,lng
    arg = lng-short if lng-short < 181 else 360-(lng-short)
    if   arg < 30: print "alert"
    elif arg < 90: print "warning"
    else         : print "safe"

Submission status: Wrong Answer

Solution code:
for roop in range(int(raw_input())):
    h,m = map(int,raw_input().split(":"))
    s = 15.0*h + m/4.0
    l = 6.0*m
    if l > s: l,s = s,l
    arg = l - s if l - s < 181 else 360-(l-s)
    if   arg < 30: print "alert"
    elif arg < 90: print "warning"
    else         : print "safe"

Submission status: Wrong Answer

Solution code:
for roop in range(int(raw_input())):
    h,m = map(int,raw_input().split(":"))
    s = 60*h + m
    l = 24*m
    if l > s: l,s = s,l
    arg = l - s if l - s < 180*4 else 360*4-(l-s)
    if   arg < 30*4: print "alert"
    elif arg < 90*4: print "warning"
    else           : print "safe"

Submission status: Wrong Answer

Solution code:
for roop in range(int(raw_input())):
    h,m = map(int,raw_input().split(":"))
    s = 60*h + m
    l = 24*m
    if l < s: l,s = s,l
    arg = l - s if l - s < 180*4 else 360*4-(l-s)
    if   arg < 30*4: print "alert"
    elif arg < 90*4: print "warning"
    else           : print "safe"

Submission status: Wrong Answer

Solution code:
for roop in range(int(raw_input())):
    h,m = map(int,raw_input().split(":"))
    s = 120*h + m
    l = 24*m
    if l < s: l,s = s,l
    arg = l - s if l - s < 180*4 else 360*4-(l-s)
    if   arg < 30*4: print "alert"
    elif arg < 90*4: print "warning"
    else           : print "safe"

Submission status: Wrong Answer

Solution code:
for _ in [0] * int(raw_input()):
  a, b = map(int, raw_input().split(':'))
  b = b/60.0
  x = abs((a+b)-b*12)
  if x<1: print 'alert'
  elif 3<=x: print 'safe'
  else: print 'warning'

Submission status: Wrong Answer

Solution code:
for _ in [0] * int(raw_input()):
  a, b = map(int, raw_input().split(':'))
  b = b/60.0
  x = abs((a+b)-b*12)
  if x>6: x=12-6
  if x<1: print 'alert'
  elif 3<=x: print 'safe'
  else: print 'warning'

Submission status: Wrong Answer

Solution code:
for _ in [0] * int(raw_input()):
  h, m = map(int, raw_input().split(':'))
  x = (h*60-m*11)%720
  if x<60: print 'alert'
  elif 180<=x: print 'safe'
  else: print 'warning'

Submission status: Wrong Answer

Solution code:
for _ in [0] * int(raw_input()):
  h, m = map(int, raw_input().split(':'))
  x = (h*60 - m*11 +720) % 720
  if x<60: print 'alert'
  elif 180<=x: print 'safe'
  else: print 'warning'

Submission status: Wrong Answer

Solution code:
n=int(raw_input())
for i in range(n):
    t=[int(x) for x in raw_input().split(':')]
    longdeg=t[1]*360/60.
    shortdeg=t[0]*360/12.+t[1]*12/60.
    (longdeg,shortdeg)=(max(longdeg,shortdeg),min(longdeg,shortdeg))
    dist=min(longdeg-shortdeg,360-(longdeg-shortdeg))
    if dist<30:
        print 'alert'
    elif dist>=90:
        print 'safe'
    else:
        print 'warning'

Submission status: Wrong Answer

Solution code:
for i in range(input()):
    h, m = map(int, raw_input().split(':'))
    s_h = h*30 + m*0.5
    l_h = m*6
    angle = abs(l_h-s_h)
    if 0 <= angle < 30:
        print 'alert'
    elif 30 <= angle < 90:
        print 'warning'
    elif 90 <= angle <= 180:
        print 'safe'

Submission status: Wrong Answer

Solution code:
n = int(input())
for i in range(n):
    m,s = map(int,input().split(":"))
    m_kak = 30 * m + 0.5 * s
    s_kak = 6 * s
    if m_kak - 30 < s_kak < m_kak + 30:
        print("alert")
    elif m_kak - 90 < s_kak < m_kak + 90:
        print("warnimg")
    else:
        print("safe")

Submission status: Wrong Answer

Solution code:
n = int(input())
for i in range(n):
    m,s = map(int,input().split(":"))
    m_kak = 30 * m + 0.5 * s
    s_kak = 6 * s
    if m_kak - 30 < s_kak < m_kak + 30:
        print("alert")
    elif m_kak - 90 < s_kak < m_kak + 90:
        print("warning")
    else:
        print("safe")

Submission status: Wrong Answer

Solution code:
def solve(h,m):
    dm = m / 60.0 * 360.0
    dh = h / 12.0 * 360.0 + 360.0/ 12.0 * m / 60.0
    print(dh, dm)
    if 0 <= abs(dh-dm) < 30.0:
        return("alert")
    elif 90.0 <= abs(dh-dm) < 180.0:
        return("safe")
    else:
        return("warning")

n = int(input().strip())
for i in range(n):
    v = list(map(int, input().strip().split(':')))
    print(solve(v[0],v[1]))

Submission status: Wrong Answer

Solution code:
def solve(h,m):
    dm = m / 60.0 * 360.0
    dh = h / 12.0 * 360.0 + 360.0/ 12.0 * m / 60.0
    x = (abs(dh-dm)+180.0) % 180.0
    if 0 <= x < 30.0:
        return("alert")
    elif 90.0 <= x < 180.0:
        return("safe")
    else:
        return("warning")

n = int(input().strip())
for i in range(n):
    v = list(map(int, input().strip().split(':')))
    print(solve(v[0],v[1]))

Submission status: Wrong Answer

Solution code:
n=int(input())
t=[[int(num)for num in input().split(':')]for i in range(n)]
for i in range(n):
    h=t[i][0]
    m=t[i][1]
    an_s=h*30+m/60
    an_l=m*6
    if abs(an_s-an_l)<30:
        print("alert")
    elif abs(an_s-an_l)<90:
        print("warning")
    else:
        print("safe")

Submission status: Wrong Answer

Solution code:
n=int(input())
t=[[int(num)for num in input().split(':')]for i in range(n)]
for i in range(n):
    h=t[i][0]
    m=t[i][1]
    an_s=h*30+m/60
    an_l=m*6
    dif=0
    if abs(an_s-an_l)<180:dif=abs(an_s-an_l)
    else:dif=360-abs(an_s-an_l)
    if dif<30:
        print("alert")
    elif dif<90:
        print("warning")
    else:
        print("safe")

Submission status: Wrong Answer

Solution code:
n=int(input())
t=[[int(num)for num in input().split(':')]for i in range(n)]
for i in range(n):
    h=t[i][0]
    m=t[i][1]
    an_s=h*30+m/120
    an_l=m*6
    dif=0
    if abs(an_s-an_l)<180:dif=abs(an_s-an_l)
    else:dif=360-abs(an_s-an_l)
    if dif<30:
        print("alert")
    elif dif<90:
        print("warning")
    else:
        print("safe")

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0135

"""
import sys
from sys import stdin
input = stdin.readline


def solve(time):
    # 12????????????0?????¨??????
    short_hand_angle = time[1] * 6
    long_hand_angle = (time[0]*60 + time[1]) / (12*60) * 360
    #print(short_hand_angle)
    #print(long_hand_angle)

    diff_angle = max(short_hand_angle, long_hand_angle) - min(short_hand_angle, long_hand_angle)
    while diff_angle > 180:
        diff_angle -= 180
    diff_angle = abs(diff_angle)

    if diff_angle < 30:
        return 'alert'
    elif 90 <= diff_angle <= 180:
        return 'safe'
    else:
        return 'warning'


def main(args):
    n = int(input())
    for _ in range(n):
        time = [int(x) for x in input().split(':')]
        result = solve(time)
        print(result)


if __name__ == '__main__':
    main(sys.argv[1:])

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0135

"""
import sys
from sys import stdin
from math import sqrt, acos, cos, sin, radians, degrees
input = stdin.readline


def solve(time):
    # 12????????????90???
    short_hand_angle = time[1] * -6 + 90
    x_s = cos(radians(short_hand_angle))
    y_s = sin(radians(short_hand_angle))

    long_hand_angle = (time[0]*60+time[1])/(12*60) * -360 + 90
    x_l = cos(radians(long_hand_angle))
    y_l = sin(radians(long_hand_angle))
    c = (x_s * x_l + y_s * y_l) / (sqrt(x_s**2 + y_s**2) * sqrt(x_l**2 + y_l**2))
    ans = degrees(acos(c))

    if ans < 30:
        return 'alert'
    elif ans > 90:
        return 'safe'
    else:
        return 'warning'


def main(args):
    n = int(input())
    for _ in range(n):
        time = [int(x) for x in input().split(':')]
        result = solve(time)
        print(result)


if __name__ == '__main__':
    main(sys.argv[1:])

Submission status: Wrong Answer

Solution code:
for _ in range(int(input())):
    hour, minute = [int(item) for item in input().split(":")]
    angle1 = hour * 5 * 6
    angle2 = minute * 6

    subtract = abs(angle1 - angle2)

    if subtract < 30:
        print("alert")
    elif 90 <= subtract:
        print("safe")
    else:
        print("warning")

Submission status: Wrong Answer

Solution code:
for _ in range(int(input())):
    hour, minute = [int(item) for item in input().split(":")]
    angle1 = hour * 5 * 6 + minute * 0.5
    angle2 = minute * 6

    subtract = min(abs(angle1 - angle2), abs(360 - angle1 - angle2))

    if subtract < 30:
        print("alert")
    elif 90 <= subtract:
        print("safe")
    else:
        print("warning")

Submission status: Wrong Answer

Solution code:
for _ in range(int(input())):
    hour, minute = [int(item) for item in input().split(":")]
    angle1 = hour * 5 * 6 + minute * 0.5
    angle2 = minute * 6

    subtract = min(abs(angle1 - angle2), abs(360 + angle1 - angle2))

    if subtract < 30:
        print("alert")
    elif 90 <= subtract:
        print("safe")
    else:
        print("warning")

Submission status: Wrong Answer

Solution code:
import math

N = int(input())

for l in range(N):
    s = input()
    hh = int(s[0:2])
    mm = int(s[3:5])

    deg2 = 6 * mm
    deg1 = 30 * hh + deg2 / 60

    #print(deg1,deg2)

    d = abs(deg1-deg2)
    if d < 30:
        print("alert")
    elif d >= 90:
        print("safe")
    else:
        print("warning")

Submission status: Wrong Answer

Solution code:
import math

N = int(input())

for l in range(N):
    s = input()
    hh = int(s[0:2])
    mm = int(s[3:5])

    deg2 = 6 * mm
    deg1 = 30 * hh + deg2 / 60

    #print(deg1, deg2)
    d = abs(deg1-deg2)
    if d < 30 or 330 < d:
        print("alert")
    elif (30 <= d and d < 90) or (270 < d and d <= 330):
        print("warning")
    else:
        print("safe")

Submission status: Wrong Answer

Solution code:
import math

N = int(input())

for l in range(N):
    s = input()
    hh = int(s[0:2])
    mm = int(s[3:5])

    deg2 = 6 * mm
    deg1 = 30 * hh + deg2 / 60

    #print(deg1, deg2)
    d = abs(deg1-deg2)
    if d < 30 or 330 < d:
        print("alert")
    elif 90 <= d and d <= 270:
        print("safe")
    else:
        print("warning")

Submission status: Wrong Answer

Solution code:
def long_angle(h, m):
  return m * 6

def short_angle(h, m):
  return 30 * h + 0.5 * m

def diff_angle(la, sa):
  return abs(la - sa) % 180

def put_mess(dff):
  if dff < 30:
    print("alert")
  elif dff < 90:
    print("warning")
  else:
    print("safe")

n = int(input())
for _ in range(n):
  h, m = list(map(int, input().split(":")))
  dff = diff_angle(long_angle(h, m), short_angle(h, m))
  put_mess(dff)

Submission status: Wrong Answer

Solution code:
n=input()
for i in range(n):
    hh,mm=map(int,raw_input().split(":"))
    angleh,anglem=30*hh,6*mm
    diff=abs(angleh-anglem)
    if 0<=diff<=30:
        print "alert"
    elif 90<=diff<=180:
        print "safe"
    else:
        print "warning"

Submission status: Wrong Answer

Solution code:
n=input()
for i in range(n):
    hh,mm=map(int,raw_input().split(":"))
    angleh,anglem=30*hh,6*mm
    diff=abs(angleh-anglem)
    if 0<=diff<30:
        print "alert"
    elif 90<=diff<=180:
        print "safe"
    else:
        print "warning"

Submission status: Wrong Answer

Solution code:
n=input()
for i in range(n):
    hh,mm=map(int,raw_input().split(":"))
    angleh,anglem=30*hh+0.5*mm,6*mm
    diff=abs(angleh-anglem)
    if 0<=diff<30:
        print "alert"
    elif 90<=diff<=180:
        print "safe"
    else:
        print "warning"

Submission status: Wrong Answer

Solution code:
import math
n=input()
for i in range(n):
    hh,mm=map(int,raw_input().split(":"))
    angleh=30*hh+0.5*mm
    anglem=6*mm
    diff=math.fabs(angleh-anglem)
    if 0<=diff<30:
        print "alert"
    elif 90<=diff<=180:
        print "safe"
    else:
        print "warning"

Submission status: Wrong Answer

Solution code:
n=input()
for i in range(n):
    hh,mm=map(int,raw_input().split(":"))
    angleh=(60*hh+mm)*0.5
    anglem=6*mm
    diff=abs(angleh-anglem)
    if 0<=diff<30:
        print "alert"
    elif 90<=diff<=180:
        print "safe"
    else:
        print "warning"

Submission status: Wrong Answer

Solution code:
# Clock Short Hand and Long Hand

n = int(raw_input())

for i in range(n):
    h, m = map(int, raw_input().split(':'))

    m *= 6.0
    h *= 30.0
    h += 30.0 * m / 360

    d = abs(m - h)
    if 0 <= d < 30:
        print "alert"
    elif 90 <= d <= 180:
        print "safe"
    else:
        print "warning"

Submission status: Wrong Answer

Solution code:
# Clock Short Hand and Long Hand

n = int(raw_input())

for i in range(n):
    h, m = map(int, raw_input().split(':'))

    m *= 6.0
    h *= 30.0
    h += 30.0 * m / 360.0

    d = abs(m - h)
    if 0 <= d < 30:
        print "alert"
    elif 90 <= d <= 180:
        print "safe"
    else:
        print "warning"

Submission status: Wrong Answer

Solution code:
# Clock Short Hand and Long Hand

n = int(raw_input())

for i in range(n):
    h, m = map(int, raw_input().split(':'))

    m *= 6.0
    h *= 30.0
    h += 30.0 * m / 360.0

    d = abs(m - h)
    if 0 <= d <= 30:
        print "alert"
    elif 90 <= d <= 180:
        print "safe"
    else:
        print "warning"

Submission status: Wrong Answer

Solution code:
# Clock Short Hand and Long Hand

n = int(raw_input())

for i in range(n):
    h, m = map(int, raw_input().split(':'))

    m *= 6.0
    h *= 30.0
    h += 30.0 * (m / 360.0)

    d = abs(m - h)
    if 0 <= d < 30:
        print "alert"
    elif 90 <= d <= 180:
        print "safe"
    else:
        print "warning"

Submission status: Wrong Answer

Solution code:
# Clock Short Hand and Long Hand

n = int(raw_input())

for i in range(n):
    h, m = map(int, raw_input().split(':'))

    m *= 6.0
    h *= 30.0
    h += m * 0.5

    d = abs(m - h)
    if 0 <= d < 30:
        print "alert"
    elif 90 <= d <= 180:
        print "safe"
    else:
        print "warning"

Submission status: Wrong Answer

Solution code:
# Clock Short Hand and Long Hand

n = int(raw_input())

for i in range(n):
    h, m = map(int, raw_input().split(':'))

    m *= 6.0
    h *= 30.0
    h += m * 0.5

    d = abs(m - h)
    d = d if d < 360 - d else d
    if 0 <= d < 30:
        print "alert"
    elif 90 <= d <= 180:
        print "safe"
    else:
        print "warning"

Submission status: Wrong Answer

Solution code:
# Clock Short Hand and Long Hand

n = int(raw_input())

for i in range(n):
    h, m = map(int, raw_input().split(':'))

    m *= 6.0
    h *= 30.0
    h += m * 0.5

    d = abs(m - h) if abs(m - h) < abs(360 + m - h) else abs(360 + m - h)
    if 0 <= d < 30:
        print "alert"
    elif 90 <= d <= 180:
        print "safe"
    else:
        print "warning"

Submission status: Wrong Answer

Solution code:
# Clock Short Hand and Long Hand

n = int(raw_input())

for i in range(n):
    h, m = map(int, raw_input().split(':'))

    m *= 6.0
    h *= 30.0
    h += m * 0.5

    d = abs(m - h)
    if d > 180:
        d = 360 - d

    if 0 <= d < 30:
        print "alert"
    elif 90 <= d <= 180:
        print "safe"
    else:
        print "warning"

Submission status: Wrong Answer

Solution code:
# Clock Short Hand and Long Hand

n = int(raw_input())

for i in range(n):
    h, m = map(int, raw_input().split(':'))

    h *= 30.0
    h += m * 0.5
    m *= 6.0

    d = abs(m - h)
    if d > 180:
        d = 360 - d

    print d

    if 0 <= d < 30:
        print "alert"
    elif 90 <= d <= 180:
        print "safe"
    else:
        print "warning"

Submission status: Wrong Answer

Solution code:
from bisect import bisect
T = [300,900]
D = ["alert","warning","safe"]
for _ in xrange(input()):
    H,M = map(int,raw_input().split(":"))
    print D[bisect(T,abs(300*H+10*M/12-M*60))]

Submission status: Wrong Answer

Solution code:
from bisect import bisect
T = [30,90,270,330]
D = ["alert","warning","safe","warning","alert"]
for _ in xrange(input()):
    H,M = map(float,raw_input().split(":"))    
    print D[bisect(T,abs(30*H+M/2-M*6))]

Submission status: Wrong Answer

Solution code:
from bisect import bisect
T = [30,90,269.5,329.5]
D = ["alert","warning","safe","warning","alert"]
for _ in xrange(input()):
    H,M = map(float,raw_input().split(":"))
    print D[bisect(T,abs(30*H+M/2-M*6))]

Submission status: Wrong Answer

Solution code:
from bisect import bisect
T = [30,90,269.6,329.6]
D = ["alert","warning","safe","warning","alert"]
for _ in xrange(input()):
    H,M = map(float,raw_input().split(":"))
    print D[bisect(T,abs(30*H+M/2-M*6))]

Submission status: Accepted

Solution code:

n = input()
for i in range(n):
    h,m = map(int, raw_input().split(":"))
    sangle = 1.0 * 360 * (h * 60 + m) / 720
    langle = 1.0 * 360 * m / 60
    angle = abs(sangle - langle)
    if angle > 180:
        angle = 360 - angle
    if (0 <= angle < 30):
        print "alert"
    elif (90 <= angle <= 180):
        print "safe"
    else:
        print "warning"

Submission status: Accepted

Solution code:
for roop in range(int(raw_input())):
    h,m = map(int,raw_input().split(":"))
    s = 120*h + 2*m
    l = 24*m
    if l < s: l,s = s,l
    arg = l - s if l - s < 180*4 else 360*4-(l-s)
    if   arg < 30*4: print "alert"
    elif arg < 90*4: print "warning"
    else           : print "safe"

Submission status: Accepted

Solution code:
for roop in range(int(raw_input())):
    h,m = map(int,raw_input().split(":"))
    s = 60*h + m
    l = 12*m
    if l < s: l,s = s,l
    arg = l - s if l - s < 180*2 else 360*2-(l-s)
    if   arg < 30*2: print "alert"
    elif arg < 90*2: print "warning"
    else           : print "safe"

Submission status: Accepted

Solution code:
for roop in range(int(raw_input())):
    h,m = map(int,raw_input().split(":"))
    s = 60*h + m
    l = 12*m
    d = abs(l-s)
    arg = d if d < 180*2 else 360*2-d
    if   arg < 30*2: print "alert"
    elif arg < 90*2: print "warning"
    else    : print "safe"

Submission status: Accepted

Solution code:
for _ in [0] * int(raw_input()):
  a, b = map(int, raw_input().split(':'))
  b = b/60.0
  x = abs((a+b)-b*12)
  if x>6: x=12-x
  if x<1: print 'alert'
  elif 3<=x: print 'safe'
  else: print 'warning'

Submission status: Accepted

Solution code:
for _ in [0] * int(raw_input()):
  a, b = map(int, raw_input().split(':'))
  x = (a*60-b*11)%720
  if x>360: x=720-x
  if x<60: print 'alert'
  elif 180<=x: print 'safe'
  else: print 'warning'

Submission status: Accepted

Solution code:
for _ in [0] * int(raw_input()):
  a, b = map(int, raw_input().split(':'))
  x = abs(a*60 - b*11)
  if x>360: x = 720-x
  if x<60: print 'alert'
  elif 180<=x: print 'safe'
  else: print 'warning'

Submission status: Accepted

Solution code:
for _ in [0] * int(raw_input()):
  h, m = map(int, raw_input().split(':'))
  x = abs(h*60 - m*11)
  x = min([x, 720-x])
  if x<60: print 'alert'
  elif 180<=x: print 'safe'
  else: print 'warning'

Submission status: Accepted

Solution code:
for _ in [0] * int(raw_input()):
  h, m = map(int, raw_input().split(':'))
  x = abs(h*60 - m*11)
  if x>360: x=720-x
  if x<60:
    print 'alert'
  elif 180<=x:
    print 'safe'
  else:
    print 'warning'

Submission status: Accepted

Solution code:
for _ in [0] * int(raw_input()):
  h, m = map(int, raw_input().split(':'))
  x = abs(h*60 - m*11)
  if x>360:
    x=720-x
  if x<60:
    print 'alert'
  elif 180<=x:
    print 'safe'
  else:
    print 'warning'

Submission status: Accepted

Solution code:
for _ in [0] * int(raw_input()):
  h, m = map(int, raw_input().split(':'))
  x = abs(h * 60 - m * 11)
  if x>360:
    x = 720 - x
  if x<60:
    print 'alert'
  elif 180<=x:
    print 'safe'
  else:
    print 'warning'

Submission status: Accepted

Solution code:
for _ in [0] * int(raw_input()):
  h, m = map(int, raw_input().split(':'))
  x = abs(h*60 - m*11)
  if x>360:
    x = 720 - x
  if x<60:
    print 'alert'
  elif 180<=x:
    print 'safe'
  else:
    print 'warning'

Submission status: Accepted

Solution code:
for _ in [0] * int(raw_input()):
  h, m = map(int, raw_input().split(':'))
  x = abs(h*60 - m*11)
  if x>360: x = 720 - x
  if x<60: print 'alert'
  elif 180<=x: print 'safe'
  else: print 'warning'

Submission status: Accepted

Solution code:
for _ in [0] * int(raw_input()):
  h, m = map(int, raw_input().split(':'))
  x = abs(h*60 - m*11)
  if x>360: x = 720 - x
  if x<60:
    print 'alert'
  elif 180<=x:
    print 'safe'
  else:
    print 'warning'

Submission status: Accepted

Solution code:
n=int(raw_input())
for i in range(n):
    t=[int(x) for x in raw_input().split(':')]
    longdeg=t[1]*360/60.
    shortdeg=t[0]*360/12.+t[1]*30/60.
    (longdeg,shortdeg)=(max(longdeg,shortdeg),min(longdeg,shortdeg))
    dist=min(longdeg-shortdeg,360-(longdeg-shortdeg))
    if dist<30:
        print 'alert'
    elif dist>=90:
        print 'safe'
    else:
        print 'warning'

Submission status: Accepted

Solution code:
for i in range(input()):
    h, m = map(int, raw_input().split(':'))
    s_h = h*30 + m*0.5
    l_h = m*6
    angle = abs(l_h-s_h)
    if 360-angle < angle:
        angle = 360 - angle
    if 0 <= angle < 30:
        print 'alert'
    elif 30 <= angle < 90:
        print 'warning'
    elif 90 <= angle <= 180:
        print 'safe'

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
'import sys'
'import math'
n=int(input())
while n:
    h,m=map(int,input().split(":"))
    s=l=float(0.0)
    l=m*6.0
    s=30.0*(h+(m/60.0))
    if l<s:l,s=s,l
    if l-s>180.0:d=360-l+s
    else:d=l-s
    if d<30: print("alert")
    elif d<90: print("warning")
    else: print("safe")
    n-=1

Submission status: Accepted

Solution code:
n=int(input())
while n:
    h,m=map(int,input().split(":"))
    s=l=.0
    l=m*6.0
    s=30.0*(h+(m/60.0))
    if l<s:l,s=s,l
    if l-s>180.0:d=360-l+s
    else:d=l-s
    if d<30: print("alert")
    elif d<90: print("warning")
    else: print("safe")
    n-=1

Submission status: Accepted

Solution code:
for _ in [0]*int(input()):
    h,m=map(int,input().split(":"))
    s=l=.0
    l=m*6
    s=30*(h+(m/60))
    if l<s:l,s=s,l
    if l-s>180:d=360-l+s
    else:d=l-s
    if d<30: print('alert')
    elif d<90: print('warning')
    else: print('safe')

Submission status: Accepted

Solution code:
for _ in [0]*int(input()):
    h,m=map(int,input().split(":"))
    s=l=.0
    l=m*6
    s=30*(h+(m/60))
    if l<s:l,s=s,l
    if l-s>180:d=360-l+s
    else:d=l-s
    b='safe'
    if d<30:b='alert'
    elif d<90: b='warning'
    print(b)

Submission status: Accepted

Solution code:
def solve(h,m):
    dh = h / 12.0 * 360.0 + 360.0/ 12.0 * m / 60.0
    dm = m / 60.0 * 360.0
    x = abs(dh-dm)
    if x > 180:
        x = 360 - x
    if 0 <= x < 30.0:
        return("alert")
    elif 90.0 <= x <= 180.0:
        return("safe")
    else:
        return("warning")

n = int(input().strip())
for i in range(n):
    v = list(map(int, input().strip().split(':')))
    print(solve(v[0],v[1]))

Submission status: Accepted

Solution code:
n=int(input())
t=[[int(num)for num in input().split(':')]for i in range(n)]
for i in range(n):
    h=t[i][0]
    m=t[i][1]
    an_s=h*30+m/2
    an_l=m*6
    dif=0
    if abs(an_s-an_l)<180:dif=abs(an_s-an_l)
    else:dif=360-abs(an_s-an_l)
    if dif<30:
        print("alert")
    elif dif<90:
        print("warning")
    else:
        print("safe")

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0135
WA
"""
import sys
from sys import stdin
from math import sqrt, acos, cos, sin, radians, degrees
input = stdin.readline


def solve(time):
    # 12????????????90???
    short_hand_angle = time[1] * -6 + 90
    x_s = cos(radians(short_hand_angle))
    y_s = sin(radians(short_hand_angle))

    long_hand_angle = (time[0]*60+time[1])/(12*60) * -360 + 90
    x_l = cos(radians(long_hand_angle))
    y_l = sin(radians(long_hand_angle))
    c = (x_s * x_l + y_s * y_l) / (sqrt(x_s**2 + y_s**2) * sqrt(x_l**2 + y_l**2))
    ans = degrees(acos(c))

    if ans < 30:
        return 'alert'
    elif ans >= 90:
        return 'safe'
    else:
        return 'warning'


def main(args):
    n = int(input())
    # n = 1
    for _ in range(n):
        time = [int(x) for x in input().split(':')]
        result = solve(time)
        print(result)


if __name__ == '__main__':
    main(sys.argv[1:])

Submission status: Accepted

Solution code:
for _ in range(int(input())):
    hour, minute = [int(item) for item in input().split(":")]
    angle1 = hour * 5 * 6 + minute * 0.5
    angle2 = minute * 6

    subtract = min(abs(angle1 - angle2), 360 - abs(angle1 - angle2))

    if subtract < 30.0:
        print("alert")
    elif 90.0 <= subtract:
        print("safe")
    else:
        print("warning")

Submission status: Accepted

Solution code:
import math

N = int(input())

for l in range(N):
    s = input()
    hh = int(s[0:2])
    mm = int(s[3:5])

    deg2 = 6 * mm
    deg1 = 30 * hh + deg2 / 12

    #print(deg1, deg2)
    d = abs(deg1-deg2)
    if d < 30 or 330 < d:
        print("alert")
    elif 90 <= d and d <= 270:
        print("safe")
    else:
        print("warning")

Submission status: Accepted

Solution code:
def long_angle(h, m):
  return m * 6

def short_angle(h, m):
  return 30 * h + 0.5 * m

def diff_angle(la, sa):
  max_a, min_a = max(la, sa), min(la, sa)
  dff = max_a - min_a
  if dff >= 180:
    return 360 - dff
  else:
    return dff


def put_mess(dff):
  if dff < 30:
    print("alert")
  elif dff < 90:
    print("warning")
  else:
    print("safe")

n = int(input())
for _ in range(n):
  h, m = list(map(int, input().split(":")))
  dff = diff_angle(long_angle(h, m), short_angle(h, m))
  put_mess(dff)

Submission status: Accepted

Solution code:
# AOJ 0135 Clock Short Hand and Long Hand
# Python3 2018.6.18 bal4u

for _ in range(int(input())):
	h, m = list(map(int, input().split(':')))
	H, M = (30*h+(m//2))*2, (6*m)*2
	if (m & 1) == 1: H += 1
	a = H-M
	if a < 0: a = -a
	a2 = 720-a
	if a2 < a: a = a2
	if a < 60: print("alert")
	elif a >= 180 and a <= 360: print("safe")
	else: print("warning")

Submission status: Accepted

Solution code:
def hdeg(h, m):
	return h * 360 / 12. + m * 360 / (12. * 60.)
def mdeg(h):
	return m * 360 / 60
for i in xrange(input()):
	h, m = map(int, raw_input().split(":"))
	d = hdeg(h, m) - mdeg(m)
	if d < 0:
		d += 360
	if d > 180:
		d = 360 - d
	if d < 30:
		print "alert"
	elif 90 <= d <= 180:
		print "safe"
	else:
		print "warning"

Submission status: Accepted

Solution code:
def calculate_angle(h, m):
    hour_hand = 360.0 * m / 60.0
    minute_hand = 360.0 * (h * 60.0 + m) / (12.0 * 60.0)

    if abs(hour_hand - minute_hand) > 180:
        angle = 360.0 - abs(hour_hand - minute_hand)
    else:
        angle = abs(hour_hand - minute_hand)

    return angle

for i in range(int(raw_input())):
    h, m = map(int, raw_input().split(':'))
    h = h % 12

    angle = calculate_angle(h, m)
    if angle < 30:
        print "alert"
    elif angle < 90:
        print "warning"
    else:
        print "safe"

Submission status: Accepted

Solution code:
n=input()
for i in range(n):
    hh,mm=map(int,raw_input().split(":"))
    angleh=(60*hh+mm)*0.5
    anglem=6*mm
    diff=abs(angleh-anglem)
    if diff>180:diff=360-diff
    if 0<=diff<30:
        print "alert"
    elif 90<=diff<=180:
        print "safe"
    else:
        print "warning"

Submission status: Accepted

Solution code:
# Clock Short Hand and Long Hand

n = int(raw_input())

for i in range(n):
    h, m = map(int, raw_input().split(':'))

    h *= 30.0
    h += m * 0.5
    m *= 6.0

    d = abs(m - h)
    if d > 180:
        d = 360 - d

    if 0 <= d < 30:
        print "alert"
    elif 90 <= d <= 180:
        print "safe"
    else:
        print "warning"

Submission status: Accepted

Solution code:
from bisect import bisect
T = [30,90,270.1,330.1]
D = ["alert","warning","safe","warning","alert"]
for _ in xrange(input()):
    H,M = map(float,raw_input().split(":"))
    print D[bisect(T,abs(30*H+M/2-M*6))]

Submission status: Accepted

Solution code:
N = int(input())
for i in range(N):
    h, m = map(int, input().split(":"))
    d = abs(60*h - 11*m)
    v = min(d, 720 - d)
    if v < 60:
        print("alert")
    elif v < 180:
        print("warning")
    else:
        print("safe")

Submission status: Accepted

Solution code:
num = int(input())

for _ in range(num):
    h, m = [int(x) for x in input().split(":")]
    
    #angle in 12 * 60 = 720 in 1/2 degree
    ha = h * 60 + m
    ma = m * 12
    da = abs(ha-ma)/2
    if da > 180:
        da = 360 - da
    
    if da >= 90:
        print("safe")
    elif da >= 30:
        print("warning")
    else:
        print("alert")

Submission status: Accepted

Solution code:
def time():
    time_h, time_m = map(int, input().split(":"))
    short = time_m / 60 * 360
    long = time_h * 30 + (time_m / 60 * 30)
    judge = min(abs(short - long), 360 - abs(short - long))
    if 0 <= judge < 30:print("alert")
    elif 30 <= judge < 90:print("warning")
    else:print("safe")
n=int(input())
for i in range(n):time()

Submission status: Accepted

Solution code:
n = int(input())

for _ in range(n):
    hh, mm = map(int, input().split(":"))
    short = mm / 60 * 360
    long = hh * 30 + (mm / 60 * 30)
    judge = min(abs(short - long), 360 - abs(short - long))

    if 0 <= judge < 30:
        print("alert")
    elif 30 <= judge < 90:
        print("warning")
    else:
        print("safe")