結果

問題 No.2373 wa, wo, n
ユーザー as277575as277575
提出日時 2023-07-07 22:18:10
言語 C++17(gcc12)
(gcc 12.3.0 + boost 1.87.0)
結果
AC  
実行時間 79 ms / 2,000 ms
コード長 1,497 bytes
コンパイル時間 1,536 ms
コンパイル使用メモリ 132,708 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-21 18:23:12
合計ジャッジ時間 3,400 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 39
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <bit>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <iostream>
#include <map>
#include <random>
#include <unordered_set>
#include <unordered_map>
#include <vector>
#include <set>
#include <string>

using namespace::std;

template<typename T, typename U>
ostream& operator<< (ostream& o, const pair<T, U>& p) {
  o << "<" << p.first << ", " << p.second << ">";
  return o;
}

template <typename T>
ostream& operator<< (ostream& o, const vector<T>& v) {
 for (const auto& x : v) o << x << " ";
 return o;
}

ostream& operator<<(ostream& o, const unordered_map<long long, long long>& m) {
  o << "{";
  for (const auto& [k, v] : m)
    o << " " << k << ": " << v << ",";
  o << "}";
  return o;
}

template <typename T>
istream& operator>> (istream& i, vector<T>& v) {
  for (auto& x : v) i >> x;
  return i;
}

int main() {
  ios::sync_with_stdio(false);
  int n;
  string s;
  cin >> n >> s;
  unordered_set<char> p {'n'};
  for (char c : s) {
    unordered_set<char> q;
    if (p.count('a') || p.count('o') || p.count('n')) {
      q.insert('w');
      q.insert('n');
    }
    if (p.count('w')) {
      q.insert('a');
      q.insert('o');
    }
    if (q.empty() || (c != '?' && !q.count(c))) {
      cout << "No" << endl;
      return 0;
    }
    p.clear();
    if (c == '?') p = q;
    else p.insert(c);
  }
   
  cout << ((p.count('a') || p.count('o') || p.count('n')) ? "Yes" : "No") << endl;
  return 0;
}

0