結果

問題 No.233 めぐるはめぐる (3)
ユーザー kazu0x17kazu0x17
提出日時 2015-07-04 01:42:55
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,084 bytes
コンパイル時間 1,623 ms
コンパイル使用メモリ 154,232 KB
実行使用メモリ 13,748 KB
最終ジャッジ日時 2023-09-22 06:08:22
合計ジャッジ時間 6,644 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 131 ms
13,328 KB
testcase_01 AC 81 ms
9,836 KB
testcase_02 AC 30 ms
6,496 KB
testcase_03 AC 81 ms
10,408 KB
testcase_04 AC 189 ms
13,496 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 186 ms
13,664 KB
testcase_08 AC 178 ms
13,748 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 73 ms
9,796 KB
testcase_13 AC 136 ms
13,392 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);
  }
  char vowel[] = {'i', 'a', 'a', 'e', 'u', 'u'};
  char consonant[] = {'n', 'b', 'm', 'g', 'r'};
  sort(consonant, consonant + 5);
  sort(vowel, vowel + 6);
  bool ok;
  string ans;
  char tmp;
  do{
    do{
      ok = true;
      for (int i = 0; i < 6; i++) {
        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[5];
        if(used.find(ans) != used.end())
          ok = false;
        if(ok){
          std::cout << ans << std::endl;
          return 0;
        }
      }
    }while(next_permutation(consonant, consonant + 5));
  }while(next_permutation(vowel, vowel + 6));
  std::cout << "NO" << std::endl;
  return 0;
}
0