結果
問題 | No.233 めぐるはめぐる (3) |
ユーザー |
|
提出日時 | 2019-01-26 20:34:02 |
言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 165 ms / 1,000 ms |
コード長 | 1,278 bytes |
コンパイル時間 | 10,132 ms |
コンパイル使用メモリ | 280,692 KB |
最終ジャッジ日時 | 2025-01-06 20:37:23 |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 11 |
ソースコード
#pragma GCC optimize("O3")#pragma GCC target("avx")#include "bits/stdc++.h"using namespace std;#define int long long#define REP(i, n) for (int i = 0; i < (n); i++)#define FOR(i, a, b) for (int i = (a); i < (b); i++)#define FORR(i, a, b) for (int i = (b - 1); i >= (a); i--)#define ALL(a) begin(a), end(a)#define let const autoint scan() {int result = 0;while (true) {auto k = getchar_unlocked();if (k < '0' || k > '9') break;result = 10 * result + k - '0';}return result;}bool is_consonant(char c) {return c == 'n' || c == 'b' || c == 'm' || c == 'g' || c == 'r';}signed main() {let n = scan();if (n == 129600) { // 最大値は計算で出せるprintf("NO\n");return 0;}auto used = unordered_set<string>();string cache = "inabameguru";REP(_, n) {REP(i, 11) cache[i] = getchar_unlocked();used.insert(cache);getchar_unlocked();};string S = "aabegimnruu";do {auto ok = true;if (is_consonant(S[10])) continue;REP(i, 11) {if (is_consonant(S[i]) && is_consonant(S[i - 1])) {ok = false;break;}}if (ok && used.find(S) == used.end()) {printf("%s\n", S.c_str());return 0;}} while (next_permutation(ALL(S)));}