結果

問題 No.233 めぐるはめぐる (3)
ユーザー kazu0x17kazu0x17
提出日時 2015-07-04 00:25:20
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 960 bytes
コンパイル時間 1,216 ms
コンパイル使用メモリ 150,000 KB
実行使用メモリ 14,760 KB
最終ジャッジ日時 2023-09-22 06:01:54
合計ジャッジ時間 4,735 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 52 ms
14,760 KB
testcase_01 AC 31 ms
5,876 KB
testcase_02 AC 18 ms
4,612 KB
testcase_03 AC 35 ms
6,140 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'};

bool vowel(char c){
  for (int i = 0; i < 5; i++) {
    if(v[i] == c)return true;
  }
  return false;
}

int main(int argc, char *argv[]){
  int n;
  cin >> n;
  string used[n];
  for (int i = 0; i < n; i++) {
    cin >> used[i];
  }
  string s = "inabameguru";
  if(n == 0){
    std::cout << s << std::endl;
    return 0;
  }
  sort(s.begin(), s.end());
  bool flag = false;
  do{
    if(!vowel(s.back()))continue;
    bool ok = true;
    for (int i = 1; i < s.length(); i++) {
      if(!vowel(s[i -  1]) && !vowel(s[i])){
        ok = false;
        break;
      }
    }
    if(!ok)continue;
    flag = true;
    for (int i = 0; i < n; i++) {
      if(used[i] != s)continue;
      flag = false;
      break;
    }
    if(flag)break;
  }while(next_permutation(s.begin(), s.end()));
  if(flag)std::cout << s << std::endl;
  else std::cout << "NO" << std::endl;
  return 0;
}

0