結果
問題 | No.2373 wa, wo, n |
ユーザー |
|
提出日時 | 2023-06-16 18:59:23 |
言語 | JavaScript (node v23.5.0) |
結果 |
AC
|
実行時間 | 503 ms / 2,000 ms |
コード長 | 1,950 bytes |
コンパイル時間 | 153 ms |
コンパイル使用メモリ | 5,120 KB |
実行使用メモリ | 108,516 KB |
最終ジャッジ日時 | 2024-07-02 11:26:06 |
合計ジャッジ時間 | 12,195 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 39 |
ソースコード
const readline = require('readline');const rl = readline.createInterface({input: process.stdin,output: process.stdout});rl.on('line', (line) => {const N = parseInt(line);rl.on('line', (line) => {const S = line.trim();const dp = new Array(N).fill(false).map(() => new Array(26).fill(false));if (S[0] === '?') {for (let j = 0; j < 26; j++) {dp[0][j] = true;}}if (S[0] === 'n') {dp[0]['n'.charCodeAt(0) - 'a'.charCodeAt(0)] = true;}if (S[0] === 'w') {dp[0]['w'.charCodeAt(0) - 'a'.charCodeAt(0)] = true;}if (S[0] === 'a' || S[0] === 'o') {console.log("No");process.exit(0);}for (let i = 1; i < N; i++) {for (let j = 0; j < 26; j++) {if (dp[i - 1][j] === true) {if (j === 'w'.charCodeAt(0) - 'a'.charCodeAt(0)) {if (S[i] === 'a') dp[i]['a'.charCodeAt(0) - 'a'.charCodeAt(0)] = true;if (S[i] === 'o') dp[i]['o'.charCodeAt(0) - 'a'.charCodeAt(0)] = true;if (S[i] === '?') {dp[i]['a'.charCodeAt(0) - 'a'.charCodeAt(0)] = true;dp[i]['o'.charCodeAt(0) - 'a'.charCodeAt(0)] = true;}} else {if (S[i] === 'w') dp[i]['w'.charCodeAt(0) - 'a'.charCodeAt(0)] = true;if (S[i] === 'n') dp[i]['n'.charCodeAt(0) - 'a'.charCodeAt(0)] = true;if (S[i] === '?') {dp[i]['w'.charCodeAt(0) - 'a'.charCodeAt(0)] = true;dp[i]['n'.charCodeAt(0) - 'a'.charCodeAt(0)] = true;}}}}}let ans = false;if (dp[N - 1]['a'.charCodeAt(0) - 'a'.charCodeAt(0)]) ans = true;if (dp[N - 1]['o'.charCodeAt(0) - 'a'.charCodeAt(0)]) ans = true;if (dp[N - 1]['n'.charCodeAt(0) - 'a'.charCodeAt(0)]) ans = true;if (ans === true) console.log("Yes");else console.log("No");process.exit(0);});});