結果

問題 No.2373 wa, wo, n
ユーザー nwonwo
提出日時 2023-06-16 19:00:42
言語 Ruby
(3.3.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,148 bytes
コンパイル時間 1,063 ms
コンパイル使用メモリ 11,464 KB
実行使用メモリ 82,536 KB
最終ジャッジ日時 2023-09-15 06:53:24
合計ジャッジ時間 20,598 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 78 ms
15,316 KB
testcase_01 AC 78 ms
15,180 KB
testcase_02 AC 79 ms
15,172 KB
testcase_03 AC 82 ms
15,144 KB
testcase_04 AC 80 ms
15,048 KB
testcase_05 AC 78 ms
15,088 KB
testcase_06 AC 79 ms
15,352 KB
testcase_07 AC 78 ms
15,144 KB
testcase_08 AC 78 ms
15,128 KB
testcase_09 AC 79 ms
15,148 KB
testcase_10 AC 79 ms
15,240 KB
testcase_11 AC 79 ms
15,140 KB
testcase_12 AC 78 ms
15,148 KB
testcase_13 AC 79 ms
15,292 KB
testcase_14 AC 855 ms
69,108 KB
testcase_15 AC 205 ms
23,988 KB
testcase_16 AC 954 ms
74,072 KB
testcase_17 AC 301 ms
31,120 KB
testcase_18 AC 99 ms
16,704 KB
testcase_19 AC 262 ms
36,672 KB
testcase_20 AC 522 ms
67,288 KB
testcase_21 AC 248 ms
35,604 KB
testcase_22 AC 368 ms
49,588 KB
testcase_23 AC 586 ms
76,268 KB
testcase_24 AC 79 ms
15,132 KB
testcase_25 AC 79 ms
15,248 KB
testcase_26 AC 78 ms
15,128 KB
testcase_27 AC 79 ms
15,352 KB
testcase_28 AC 80 ms
15,136 KB
testcase_29 AC 79 ms
15,152 KB
testcase_30 AC 78 ms
15,152 KB
testcase_31 AC 78 ms
15,244 KB
testcase_32 AC 1,075 ms
82,532 KB
testcase_33 AC 619 ms
81,620 KB
testcase_34 TLE -
testcase_35 AC 612 ms
81,488 KB
testcase_36 AC 948 ms
82,164 KB
testcase_37 AC 955 ms
82,536 KB
testcase_38 AC 956 ms
82,308 KB
testcase_39 AC 964 ms
81,912 KB
testcase_40 AC 989 ms
82,320 KB
testcase_41 AC 1,002 ms
82,360 KB
testcase_42 AC 1,132 ms
82,524 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

N = gets.to_i
S = gets.chomp

dp = Array.new(N) { Array.new(26, false) }
if S[0] == '?'
  26.times { |j| dp[0][j] = true }
end
if S[0] == 'n'
  dp[0]['n'.ord - 'a'.ord] = true
end
if S[0] == 'w'
  dp[0]['w'.ord - 'a'.ord] = true
end
if S[0] == 'a' || S[0] == 'o'
  puts "No"
  exit
end

1.upto(N - 1) do |i|
  0.upto(25) do |j|
    if dp[i - 1][j]
      if j == 'w'.ord - 'a'.ord
        if S[i] == 'a'
          dp[i]['a'.ord - 'a'.ord] = true
        end
        if S[i] == 'o'
          dp[i]['o'.ord - 'a'.ord] = true
        end
        if S[i] == '?'
          dp[i]['a'.ord - 'a'.ord] = true
          dp[i]['o'.ord - 'a'.ord] = true
        end
      else
        if S[i] == 'w'
          dp[i]['w'.ord - 'a'.ord] = true
        end
        if S[i] == 'n'
          dp[i]['n'.ord - 'a'.ord] = true
        end
        if S[i] == '?'
          dp[i]['w'.ord - 'a'.ord] = true
          dp[i]['n'.ord - 'a'.ord] = true
        end
      end
    end
  end
end

ans = false
ans = true if dp[N - 1]['a'.ord - 'a'.ord]
ans = true if dp[N - 1]['o'.ord - 'a'.ord]
ans = true if dp[N - 1]['n'.ord - 'a'.ord]

if ans
  puts "Yes"
else
  puts "No"
end
0