結果
| 問題 | 
                            No.233 めぐるはめぐる (3)
                             | 
                    
| コンテスト | |
| ユーザー | 
                             どらら
                         | 
                    
| 提出日時 | 2015-06-26 23:53:58 | 
| 言語 | C++11(廃止可能性あり)  (gcc 13.3.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 1,830 bytes | 
| コンパイル時間 | 795 ms | 
| コンパイル使用メモリ | 90,948 KB | 
| 実行使用メモリ | 13,568 KB | 
| 最終ジャッジ日時 | 2024-07-07 19:19:38 | 
| 合計ジャッジ時間 | 5,250 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge4 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 9 WA * 2 | 
ソースコード
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <iostream>
#include <queue>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
map<string,int> memo;
bool finished;
bool isvowel(char c){
  if(c=='n' ||
     c=='b' ||
     c=='m' ||
     c=='g' ||
     c=='r') return false;
  return true;
}
void solve(string& str, string dst){
  if(finished) return;
  if(str == "***********"){
    if(isvowel(dst[dst.size()-1]) && memo.count(dst) == 0){
      cout << dst << endl;
      finished = true;
    }
    return;
  }
  if(dst.length() >= 3){
    if(isvowel(dst[dst.size()-1]) &&
       isvowel(dst[dst.size()-2]) &&
       isvowel(dst[dst.size()-3])){
      return;
    }
  }
  if(dst == ""){
    rep(i,str.length()){
      char c = str[i];
      str[i] = '*';
      solve(str, dst+c);
      str[i] = c;
    }
  }else{
    if(!isvowel(dst[dst.size()-1])){
      rep(i,str.length()){
        if(str[i] == '*') continue;
        if(!isvowel(str[i])) continue;
        char c = str[i];
        str[i] = '*';
        solve(str, dst+c);
        str[i] = c;
      }
    }else{
      rep(i,str.length()){
        if(str[i] == '*') continue;
        char c = str[i];
        str[i] = '*';
        solve(str, dst+c);
        str[i] = c;
      }
    }
  }
}
int main(){
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  rep(i,N){
    string str;
    cin >> str;
    memo[str]++;
  }
  finished = false;
  string name = "inabameguru";
  solve(name, "");
  
  return 0;
}
            
            
            
        
            
どらら