結果

問題 No.233 めぐるはめぐる (3)
ユーザー どららどらら
提出日時 2015-06-26 23:51:42
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,799 bytes
コンパイル時間 682 ms
コンパイル使用メモリ 84,780 KB
実行使用メモリ 13,520 KB
最終ジャッジ日時 2023-09-22 01:53:19
合計ジャッジ時間 6,352 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 117 ms
13,116 KB
testcase_01 AC 72 ms
9,708 KB
testcase_02 AC 33 ms
6,612 KB
testcase_03 AC 81 ms
10,336 KB
testcase_04 AC 523 ms
13,520 KB
testcase_05 AC 472 ms
13,452 KB
testcase_06 AC 440 ms
13,476 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 73 ms
9,724 KB
testcase_13 AC 118 ms
13,288 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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