結果

問題 No.233 めぐるはめぐる (3)
ユーザー kazu0x17kazu0x17
提出日時 2015-07-03 23:58:41
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 876 bytes
コンパイル時間 1,395 ms
コンパイル使用メモリ 155,320 KB
実行使用メモリ 13,072 KB
最終ジャッジ日時 2023-09-22 05:58:56
合計ジャッジ時間 6,488 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 269 ms
13,072 KB
testcase_01 AC 77 ms
9,768 KB
testcase_02 AC 39 ms
6,500 KB
testcase_03 AC 102 ms
10,400 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[]){
  set<string> used;
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    used.insert(s);
  }
  string s = "inabameguru";
  sort(s.begin(), s.end());
  bool flag;
  do{
    bool ok = true;
    for (int i = 1; i < s.length(); i++) {
      if(!vowel(s[i -  1]) && !vowel(s[i])){
        ok = false;
        break;
      }
    }
    if(!ok || !vowel(s.back()))continue;
    flag = true;
    for (string ss:used){
      if(s != ss)continue;
      flag = false;
    }
    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