Official

A - Vacation Validation Editorial by en_translator


For beginners

Use a for statement to inspect the \(L\)-th through \(R\)-th characters of \(S\). Once you find x, you may print No and terminate the program right away; this makes the implementation easier.

Note that in most programming languages, the index of a string or an array starts with \(0\).

Sample code (Python)

N, L, R = map(int,input().split())
S = input()
for i in range(L-1, R):
  if S[i] == 'x':
    print("No")
    exit()

print("Yes")

この他、「~の全てが~か?」などの判定を行うことができるメソッドを用いたり、文字列として比較するなどの方法により、for文を明示的に使うことなく解くこともできます。 Alternatively, you can implement it without using a for statement, by using a method that can check if “does all of them satisfy this condition?” or using string comparison.

Sample code (Python)

N, L, R = map(int,input().split())
S = input()
if all(c == 'o' for c in S[L-1:R]):
  print("Yes")
else:
  print("No")

Sample code (Python)

N, L, R = map(int,input().split())
S = input()
if S[L-1:R] == "o" * (R-L+1):
  print("Yes")
else:
  print("No")

posted:
last update: