結果

問題 No.2373 wa, wo, n
ユーザー tnakao0123tnakao0123
提出日時 2023-07-10 18:49:18
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 4 ms / 2,000 ms
コード長 664 bytes
コンパイル時間 326 ms
コンパイル使用メモリ 42,052 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-09-12 23:44:06
合計ジャッジ時間 1,663 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 39
権限があれば一括ダウンロードができます

ソースコード

diff #

/* -*- coding: utf-8 -*-
 *
 * 2373.cc:  No.2373 wa, wo, n - yukicoder
 */

#include<cstdio>
#include<algorithm>
 
using namespace std;

/* constant */

const int MAX_N = 200000;

/* typedef */

/* global variables */

char s[MAX_N + 4];
bool dp[MAX_N + 1];

/* subroutines */

/* main */

int main() {
  int n;
  scanf("%d%s", &n, s);

  dp[0] = true;
  for (int i = 0; i < n; i++)
    if (dp[i]) {
      if (s[i] == 'n' || s[i] == '?')
	dp[i + 1] = true;
      if (i + 2 <= n &&
	  (s[i] == 'w' || s[i] == '?') &&
	  (s[i + 1] == 'a' || s[i + 1] == 'o' || s[i + 1] == '?'))
	dp[i + 2] = true;
    }

  if (dp[n]) puts("Yes");
  else puts("No");
  
  return 0;
}
0