結果
問題 | No.233 めぐるはめぐる (3) |
ユーザー |
|
提出日時 | 2019-01-26 21:11:35 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 51 ms / 1,000 ms |
コード長 | 1,347 bytes |
コンパイル時間 | 2,278 ms |
コンパイル使用メモリ | 189,396 KB |
実行使用メモリ | 12,772 KB |
最終ジャッジ日時 | 2024-09-18 22:41:32 |
合計ジャッジ時間 | 4,274 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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;}string S = "aaeiuu";string C = "bgmnr";string SC = "aaeiuubgmnr";auto used = unordered_set<string>();bool check() {if (used.find(SC) == used.end()) {printf("%s\n", SC.c_str());return true;}return false;}signed main() {let n = scan();if (n == 129600) { // 最大値は計算で出せるprintf("NO\n");return 0;}string cache = "inabameguru";REP(_, n) {REP(i, 11) cache[i] = getchar_unlocked();used.insert(cache);getchar_unlocked();};do {do {SC[0] = S[0];FOR(i, 0, 5) {SC[i * 2 + 2] = S[i + 1];SC[i * 2 + 1] = C[i];}REP(i, 5) {if (check()) return 0;swap(SC[i * 2], SC[i * 2 + 1]);}if (check()) return 0;} while (next_permutation(ALL(C)));} while (next_permutation(ALL(S)));}