結果

問題 No.233 めぐるはめぐる (3)
ユーザー どららどらら
提出日時 2015-06-26 23:53:58
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,830 bytes
コンパイル時間 839 ms
コンパイル使用メモリ 84,904 KB
実行使用メモリ 13,680 KB
最終ジャッジ日時 2023-09-22 02:31:23
合計ジャッジ時間 7,356 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 136 ms
13,276 KB
testcase_01 AC 76 ms
9,672 KB
testcase_02 AC 27 ms
6,532 KB
testcase_03 AC 87 ms
10,364 KB
testcase_04 AC 559 ms
13,556 KB
testcase_05 AC 486 ms
13,492 KB
testcase_06 AC 457 ms
13,464 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 72 ms
9,704 KB
testcase_13 AC 126 ms
13,320 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(){
  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;
}
0