結果

問題 No.233 めぐるはめぐる (3)
ユーザー kazu0x17kazu0x17
提出日時 2015-07-04 00:49:33
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 1,183 bytes
コンパイル時間 1,414 ms
コンパイル使用メモリ 151,596 KB
実行使用メモリ 11,624 KB
最終ジャッジ日時 2023-09-22 06:04:22
合計ジャッジ時間 5,121 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 60 ms
11,624 KB
testcase_01 AC 28 ms
5,924 KB
testcase_02 AC 15 ms
4,724 KB
testcase_03 AC 37 ms
6,212 KB
testcase_04 TLE -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
char v[] = {'a', 'i', 'u', 'e', 'o'};

int main(int argc, char *argv[]){
  int n;
  cin >> n;
  string used[n];
  for (int i = 0; i < n; i++) {
    cin >> used[i];
  }
  string vowel = "iaaeuu";
  string consonant = "nbmgr";
  sort(vowel.begin(), vowel.end());
  sort(consonant.begin(), consonant.end());
  bool ok;
  string ans;
  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.substr(j, 1);
            seq++;
          }
          ans += consonant.substr(j, 1) + vowel.substr(j + seq, 1);
        }
        if(seq == 0)ans += vowel.substr(5, 1);
        //std::cout << ans << std::endl;
        for (int j = 0; j < n; j++) {
          if(used[j] != ans)continue;
          ok = false;
          break;
        }
        if(ok)break;
      }
      if(ok)break;
    }while(next_permutation(consonant.begin(), consonant.end()));
    if(ok)break;
  }while(next_permutation(vowel.begin(), vowel.end()));
  if(ok)std::cout << ans << std::endl;
  else std::cout << "NO" << std::endl;

  return 0;
}

0