結果

問題 No.233 めぐるはめぐる (3)
コンテスト
ユーザー どらら
提出日時 2015-06-26 23:51:42
言語 C++11
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=gnu++11 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 1,799 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 657 ms
コンパイル使用メモリ 114,192 KB
実行使用メモリ 13,696 KB
最終ジャッジ日時 2026-03-29 09:38:48
合計ジャッジ時間 4,537 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 9 WA * 2
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#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(){
  int N;
  cin >> N;

  rep(i,N){
    string str;
    cin >> str;
    memo[str]++;
  }

  finished = false;
  string name = "inabameguru";
  solve(name, "");
  
  return 0;
}
0