結果

問題 No.2373 wa, wo, n
ユーザー umezo
提出日時 2023-07-09 06:58:38
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 27 ms / 2,000 ms
コード長 633 bytes
コンパイル時間 1,772 ms
コンパイル使用メモリ 194,268 KB
最終ジャッジ日時 2025-02-15 09:17:39
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 39
権限があれば一括ダウンロードができます

ソースコード

diff #

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

#include <bits/stdc++.h>
using namespace std;

int dp[200200];

int main(){
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);

  int n;
  string s;
  cin>>n>>s;
  dp[0]=1;
  rep(i,n){
    if(dp[i]==0) continue;
    if(s[i]=='?' || s[i]=='n') dp[i+1]=1;
    if(i<n-1){
      if(s.substr(i,2)=="wa" || s.substr(i,2)=="wo" || s.substr(i,2)=="??" ||
       s.substr(i,2)=="?a" || s.substr(i,2)=="?o" || s.substr(i,2)=="w?")
      dp[i+2]=1;
    }
  }
  if(dp[n]) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;

  return 0;
}
0