結果

問題 No.233 めぐるはめぐる (3)
ユーザー kazu0x17
提出日時 2015-07-04 02:01:34
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 109 ms / 1,000 ms
コード長 988 bytes
コンパイル時間 1,619 ms
コンパイル使用メモリ 169,640 KB
実行使用メモリ 13,440 KB
最終ジャッジ日時 2024-07-07 22:52:30
合計ジャッジ時間 4,250 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 11
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main(int argc, char *argv[]){
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  set<string> used;
  for (int i = 0; i < n; i++) {
    string tmp;
    cin >> tmp;
    used.insert(tmp);
  }
  string vowel = "aaeiuu";
  string consonant = "bgmnr";
  sort(consonant.begin(), consonant.end());
  sort(vowel.begin(), vowel.end());
  do{
    do{
      for (int i = 0; i < 6; i++) {
        string ans;
        int seq = 0;
        for (int j = 0; j < 5; j++) {
          if(i == j){
            ans += vowel[j];
            seq++;
          }
          ans += consonant[j];
          ans += vowel[j + seq];
        }
        if(seq == 0)ans += vowel.back();
        if(used.count(ans) == 0){
          std::cout << ans << std::endl;
          return 0;
        }
      }
    }while(next_permutation(consonant.begin(), consonant.end()));
  }while(next_permutation(vowel.begin(), vowel.end()));
  std::cout << "NO" << std::endl;
  return 0;
}
0