Last time It is C today. Today is the end of the example.
#16
** Thoughts ** ABC049-C I didn't understand at all, so I looked at the explanation. Hmmm, is it not necessary to distinguish er by reversing the character string? After reversing the character string, I just make it an if statement.
s = str(input())
s = ''.join(list(reversed(s)))
t = 0
while t <= len(s):
if s[t:t+5] == 'maerd':
t += 5
continue
elif s[t:t+7] == 'remaerd':
t += 7
continue
elif s[t:t+5] == 'esare':
t += 5
continue
elif s[t:t+6] == 'resare':
t += 6
continue
elif t == len(s):
print('YES')
quit()
else:
break
print('NO')
Python3 → 33ms PyPy3 → 189ms Is Python faster than PyPy for slicing?
ABC086-C Required [Manhattan Distance?] When moving from (0,0) to (x, y) (https://ja.wikipedia.org/wiki/%E3%83%9E%E3%83%B3%E3 If% 83% 8F% E3% 83% 83% E3% 82% BF% E3% 83% B3% E8% B7% 9D% E9% 9B% A2) is d, you can arrive in time if t> = d. I will. Also, if (d --t)% 2 == 0, even if you arrive less than t, you can go back and forth between the adjacent square and the target square, so you can arrive at t.
n = int(input())
l = [list(map(int,input().split())) for _ in range(n)]
for i in range(n):
t = l[i][0]
x = l[i][1]
y = l[i][2]
d = x + y
if d <= t and (d - t) % 2 == 0:
continue
else:
print('No')
quit()
print('Yes')
Python3 → 369ms PyPy3 → 585ms
I've solved all the examples this time, so I'll solve similar problems from the next time! see you
Recommended Posts