結果
問題 | No.2373 wa, wo, n |
ユーザー |
|
提出日時 | 2023-07-07 21:45:05 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 16 ms / 2,000 ms |
コード長 | 1,076 bytes |
コンパイル時間 | 1,943 ms |
コンパイル使用メモリ | 192,552 KB |
最終ジャッジ日時 | 2025-02-15 07:04:40 |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 39 |
ソースコード
#include <bits/stdc++.h>using namespace std;int main () {int N;cin >> N;bool ok[4] = {true, false, false, false};bool G[4][4] = {{false, true, true, false},{false, false, true, true},{false, true, true, false},{false, true, true, false}};string key = "?wnao";for (int i = 0; i < N; i ++) {char c;cin >> c;bool did = false;for (int j = 0; j < 5; j ++) {if (key[j] != c) {continue;}if (j) {j = min(j, 3);bool ok2[4];for (int k = 0; k < 4; k ++) {ok2[k] = false;}for (int k = 0; k < 4; k ++) {ok2[j] = ok2[j] || (ok[k] && G[k][j]);}for (int k = 0; k < 4; k ++) {ok[k] = ok2[k];}} else {bool ok2[4];for (int k = 0; k < 4; k ++) {ok2[k] = false;for (int l = 0; l < 4; l ++) {ok2[k] = ok2[k] || (ok[l] && G[l][k]);}}for (int k = 0; k < 4; k ++) ok[k] = ok2[k];}did = true;break;}if (!did) {puts("No");return 0;}}if (ok[0] || ok[2] || ok[3]) {puts("Yes");} else {puts("No");}}