結果

問題 No.2373 wa, wo, n
ユーザー McGregorshMcGregorsh
提出日時 2023-07-07 22:00:29
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 353 ms / 2,000 ms
コード長 2,700 bytes
コンパイル時間 482 ms
コンパイル使用メモリ 87,264 KB
実行使用メモリ 123,668 KB
最終ジャッジ日時 2023-09-28 23:15:32
合計ジャッジ時間 15,432 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 238 ms
90,092 KB
testcase_01 AC 237 ms
90,060 KB
testcase_02 AC 241 ms
89,876 KB
testcase_03 AC 238 ms
89,948 KB
testcase_04 AC 238 ms
90,060 KB
testcase_05 AC 239 ms
90,068 KB
testcase_06 AC 238 ms
90,112 KB
testcase_07 AC 239 ms
89,940 KB
testcase_08 AC 241 ms
89,992 KB
testcase_09 AC 241 ms
90,100 KB
testcase_10 AC 241 ms
89,884 KB
testcase_11 AC 243 ms
90,100 KB
testcase_12 AC 243 ms
89,944 KB
testcase_13 AC 245 ms
89,920 KB
testcase_14 AC 347 ms
118,068 KB
testcase_15 AC 302 ms
96,876 KB
testcase_16 AC 347 ms
120,108 KB
testcase_17 AC 311 ms
100,136 KB
testcase_18 AC 266 ms
91,032 KB
testcase_19 AC 272 ms
101,680 KB
testcase_20 AC 285 ms
107,372 KB
testcase_21 AC 276 ms
101,548 KB
testcase_22 AC 284 ms
106,184 KB
testcase_23 AC 290 ms
107,648 KB
testcase_24 AC 236 ms
89,944 KB
testcase_25 AC 241 ms
89,912 KB
testcase_26 AC 240 ms
89,900 KB
testcase_27 AC 243 ms
89,924 KB
testcase_28 AC 244 ms
89,788 KB
testcase_29 AC 241 ms
89,940 KB
testcase_30 AC 238 ms
90,092 KB
testcase_31 AC 238 ms
90,108 KB
testcase_32 AC 349 ms
123,668 KB
testcase_33 AC 287 ms
107,848 KB
testcase_34 AC 276 ms
107,948 KB
testcase_35 AC 269 ms
107,828 KB
testcase_36 AC 315 ms
122,736 KB
testcase_37 AC 278 ms
107,852 KB
testcase_38 AC 279 ms
108,044 KB
testcase_39 AC 276 ms
107,892 KB
testcase_40 AC 347 ms
123,380 KB
testcase_41 AC 353 ms
123,204 KB
testcase_42 AC 289 ms
107,764 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
from sys import stdin
from fractions import Fraction
import math
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque, defaultdict
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement, permutations
from bisect import bisect, bisect_left, bisect_right
from functools import reduce, lru_cache
from decimal import Decimal, getcontext, ROUND_HALF_UP
def i_input(): return int(stdin.readline())
def i_map(): return map(int, stdin.readline().split())
def i_list(): return list(i_map())
def s_input(): return stdin.readline()[:-1]
def s_map(): return s_input().split()
def s_list(): return list(s_map())
def lcm(a, b): return a * b // gcd(a, b)
def get_distance(x1, y1, x2, y2):
	  d = sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2)
	  return d
def rotate(table):
   	  n_fild = []
   	  for x in zip(*table[::-1]):
   	  	  n_fild.append(x)
   	  return n_fild
sys.setrecursionlimit(10 ** 7)
INF = float('inf')
MOD = 10 ** 9 + 7
MOD2 = 998244353
alpa = 'abcdefghijklmnopqrstuvwxyz'
ALPA = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'


def main():
   
   N = int(input())
   S = list(input())
   
   dp = [[False] * 5 for i in range(N)]
   if S[0] == 'w':
   	  dp[0][0] = True
   if S[0] == 'n':
   	  dp[0][3] = True
   if S[0] == '?':
   	  dp[0][4] = True 
   
   for i in range(1, N):
   	  p = S[i]
   	  if p == 'w':
   	  	  if dp[i-1][1]:
   	  	  	  dp[i][0] = True
   	  	  if dp[i-1][2]:
   	  	  	  dp[i][0] = True
   	  	  if dp[i-1][3]:
   	  	  	  dp[i][0] = True
   	  	  if dp[i-1][4]:
   	  	  	  dp[i][0] = True
   	  if p == 'a':
   	  	   if dp[i-1][0]:
   	  	  	  dp[i][1] = True
   	  	   if dp[i-1][4]:
   	  	   	  dp[i][1] = True
   	  if p == 'o':
   	  	  if dp[i-1][0]:
   	  	  	  dp[i][2] = True
   	  	  if dp[i-1][4]:
   	  	   	  dp[i][2] = True
   	  if p == 'n':
   	  	  if dp[i-1][1]:
   	  	  	  dp[i][3] = True
   	  	  if dp[i-1][2]:
   	  	  	  dp[i][3] = True
   	  	  if dp[i-1][3]:
   	  	  	  dp[i][3] = True
   	  	  if dp[i-1][4]:
   	  	  	  dp[i][3] = True
   	  if p == '?':
   	  	  if dp[i-1][0]:
   	  	  	  dp[i][1] = True
   	  	  	  dp[i][2] = True
   	  	  if dp[i-1][1]:
   	  	  	  dp[i][4] = True
   	  	  if dp[i-1][2]:
   	  	  	  dp[i][4] = True
   	  	  if dp[i-1][3]:
   	  	  	  dp[i][4] = True
   	  	  if dp[i-1][4]:
   	  	  	  dp[i][4] = True
   	  	  
   	  	  
   	  juge = 'waon?'
   	  if p not in juge:
   	  	  print('No')
   	  	  exit()
   
   for i in range(1, 5):
   	  if dp[-1][i]:
   	  	  print('Yes')
   	  	  exit()
   print('No')
   
if __name__ == '__main__':
    main()












0