結果

問題 No.233 めぐるはめぐる (3)
ユーザー kazu0x17kazu0x17
提出日時 2015-07-04 02:01:34
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 193 ms / 1,000 ms
コード長 988 bytes
コンパイル時間 1,433 ms
コンパイル使用メモリ 156,172 KB
実行使用メモリ 13,560 KB
最終ジャッジ日時 2023-09-22 06:08:36
合計ジャッジ時間 5,647 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 122 ms
13,092 KB
testcase_01 AC 70 ms
9,796 KB
testcase_02 AC 29 ms
6,508 KB
testcase_03 AC 81 ms
10,560 KB
testcase_04 AC 193 ms
13,504 KB
testcase_05 AC 154 ms
13,560 KB
testcase_06 AC 145 ms
13,500 KB
testcase_07 AC 177 ms
13,532 KB
testcase_08 AC 186 ms
13,492 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 65 ms
10,000 KB
testcase_13 AC 127 ms
13,396 KB
権限があれば一括ダウンロードができます

ソースコード

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