結果

問題 No.233 めぐるはめぐる (3)
ユーザー beetbeet
提出日時 2018-11-15 17:38:39
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 272 ms / 1,000 ms
コード長 887 bytes
コンパイル時間 2,041 ms
コンパイル使用メモリ 211,804 KB
実行使用メモリ 8,336 KB
最終ジャッジ日時 2023-08-26 01:21:41
合計ジャッジ時間 5,485 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
7,544 KB
testcase_01 AC 53 ms
8,232 KB
testcase_02 AC 27 ms
5,112 KB
testcase_03 AC 58 ms
7,728 KB
testcase_04 AC 267 ms
8,292 KB
testcase_05 AC 156 ms
8,156 KB
testcase_06 AC 150 ms
8,064 KB
testcase_07 AC 272 ms
7,404 KB
testcase_08 AC 270 ms
8,088 KB
testcase_09 AC 4 ms
4,384 KB
testcase_10 AC 4 ms
4,380 KB
testcase_11 AC 4 ms
4,380 KB
testcase_12 AC 53 ms
8,336 KB
testcase_13 AC 83 ms
8,076 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  int n;
  cin>>n;
  vector<string> ss;
  for(int i=0;i<n;i++){
    string s;
    cin>>s;
    ss.emplace_back(s);
  }
  sort(ss.begin(),ss.end());
  
  string b="inabameguru";
  sort(b.begin(),b.end());
  auto is_b=[](char c){return c=='a'||c=='i'||c=='u'||c=='e'||c=='o';};
  int p=0;
  do{
    if(p<(int)ss.size()&&ss[p]==b){
      p++;
      continue;
    }
    if(!is_b(b.back())) continue;
    int flg=0;
    for(int i=0;i+1<(int)b.size();i++)
      flg|=!is_b(b[i])&&!is_b(b[i+1]);
    if(flg) continue;
    cout<<b<<endl;
    return 0;
  }while(next_permutation(b.begin(),b.end()));
  
  cout<<"NO"<<endl;
  return 0;
}
0