結果

問題 No.2373 wa, wo, n
ユーザー nwonwo
提出日時 2023-06-16 19:04:45
言語 Ruby
(3.3.0)
結果
AC  
実行時間 1,361 ms / 2,000 ms
コード長 962 bytes
コンパイル時間 426 ms
コンパイル使用メモリ 11,496 KB
実行使用メモリ 82,516 KB
最終ジャッジ日時 2023-09-15 06:54:02
合計ジャッジ時間 17,373 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 81 ms
15,304 KB
testcase_01 AC 81 ms
15,140 KB
testcase_02 AC 80 ms
15,356 KB
testcase_03 AC 81 ms
15,164 KB
testcase_04 AC 81 ms
15,136 KB
testcase_05 AC 82 ms
15,204 KB
testcase_06 AC 83 ms
15,244 KB
testcase_07 AC 83 ms
15,092 KB
testcase_08 AC 83 ms
15,240 KB
testcase_09 AC 82 ms
15,300 KB
testcase_10 AC 83 ms
15,100 KB
testcase_11 AC 81 ms
15,252 KB
testcase_12 AC 83 ms
15,032 KB
testcase_13 AC 82 ms
15,148 KB
testcase_14 AC 707 ms
69,316 KB
testcase_15 AC 183 ms
24,192 KB
testcase_16 AC 758 ms
74,196 KB
testcase_17 AC 258 ms
31,228 KB
testcase_18 AC 99 ms
16,720 KB
testcase_19 AC 246 ms
36,996 KB
testcase_20 AC 477 ms
67,224 KB
testcase_21 AC 234 ms
35,664 KB
testcase_22 AC 347 ms
49,596 KB
testcase_23 AC 535 ms
76,280 KB
testcase_24 AC 80 ms
15,036 KB
testcase_25 AC 80 ms
15,160 KB
testcase_26 AC 81 ms
15,168 KB
testcase_27 AC 82 ms
15,248 KB
testcase_28 AC 80 ms
15,088 KB
testcase_29 AC 81 ms
15,088 KB
testcase_30 AC 80 ms
15,092 KB
testcase_31 AC 81 ms
15,088 KB
testcase_32 AC 864 ms
82,304 KB
testcase_33 AC 576 ms
81,516 KB
testcase_34 AC 1,361 ms
82,516 KB
testcase_35 AC 567 ms
81,472 KB
testcase_36 AC 803 ms
82,240 KB
testcase_37 AC 802 ms
82,316 KB
testcase_38 AC 803 ms
82,512 KB
testcase_39 AC 822 ms
82,144 KB
testcase_40 AC 823 ms
82,328 KB
testcase_41 AC 821 ms
82,152 KB
testcase_42 AC 898 ms
82,512 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

lines = readlines.map(&:chomp)
N = lines[0].to_i
S = lines[1]

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][13] = true
end
if S[0] == 'w'
  dp[0][22] = true
end
if S[0] == 'a' || S[0] == 'o'
  puts "No"
  exit
end

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

ans = dp[N - 1][0] || dp[N - 1][14] || dp[N - 1][13]

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