QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#622689#8841. North North WestmaspyAC ✓24ms11704kbPython3272b2024-10-09 00:08:052024-10-09 00:08:05

Judging History

This is the latest submission verdict.

  • [2024-10-09 00:08:05]
  • Judged
  • Verdict: AC
  • Time: 24ms
  • Memory: 11704kb
  • [2024-10-09 00:08:05]
  • Submitted

answer

from fractions import Fraction
while 1:
  S=input()
  if S=='#':
    break
  S=S.replace('north','n').replace('west','w')
  d=Fraction(90,1)
  for i,s in enumerate(S[::-1]):
    if not i:
      x=90if s=='n'else 0
    x+=-d if s=='n' else d
    d/=2
  print(x)

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 24ms
memory: 11704kb

input:

north
west
northwest
northnorthwest
westwestwestnorth
#

output:

0
90
45
45/2
315/4

result:

ok 5 tokens

Test #2:

score: 0
Accepted
time: 24ms
memory: 11704kb

input:

north
west
northwest
northnorthwest
westwestwestnorth
westnorth
westwestwestnorthwest
west
northwest
northnorthnorthwestnorth
northwestnorthwest
westwestwestnorth
northwestnorth
north
westnorth
westnorthwestnorthwestwestnorthwestwestnorth
northnorthwestnorthwestwestwestnorthnorthnorthwestwestnorthno...

output:

0
90
45
45/2
315/4
45
675/8
90
45
45/8
225/4
315/4
45/2
0
45
16335/256
286965/16384
1188585/16384
70065/1024
59985/2048
45/128
4005/64
5085/256
34785/1024
585/32
45/4096
765/64
225/32
974925/65536
2386665/32768
771075/131072
90
3778065/65536
20745/256
92115/1024
2835/32

result:

ok 36 tokens