結果

問題 No.233 めぐるはめぐる (3)
ユーザー syoken_desukasyoken_desuka
提出日時 2015-07-02 23:07:41
言語 C++11
(gcc 11.4.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 2,218 bytes
コンパイル時間 810 ms
コンパイル使用メモリ 90,776 KB
実行使用メモリ 17,816 KB
最終ジャッジ日時 2023-09-22 05:47:20
合計ジャッジ時間 8,150 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 6 ms
4,380 KB
testcase_12 WA -
testcase_13 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <array>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include<complex>
#include <cmath>
#include <iostream>
#include <fstream>
#include <queue>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <string>
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;

char nameChars1[6] = {'i','a','a','e','u','u'};
char nameChars2[5] = {'n','b','m','g','r'};
char ans[11];
bool used[11]; 
set<string> usedNames;

bool judge()
{
    /*
    bool beforeBoin = false;
    rep(i,11)
    {
        REP(j,0,5)
        {
            if (ans[i] == nameChars2[j])
            {
                if (i == 10)return false; //name no saigo ga siin
                if (beforeBoin) return false;
                else beforeBoin = true;
                goto SKIP_I;
            }
        }    
        beforeBoin = false;
SKIP_I:;
    }*/
    return usedNames.find(ans) == usedNames.end();
}

bool f_find(int count, bool beforeSiin)
{
    if (count == 11)
    {
        return  usedNames.find(ans) == usedNames.end();//judge();
    }
    rep(i,6)
    {
        if (!used[i])
        {
            ans[count] = nameChars1[i];
            used[i] = true;
            if (f_find(count+1,false)) return true;
            used[i] = false;
            ans[count] = ' ';
        }
    }
    if (!beforeSiin)
    {
        if (count == 10) return false;
        rep(i,5)
        {           
            if (!used[6+i])
            {
                ans[count] = nameChars2[i];
                used[6+i] = true;
                if (f_find(count+1, true))return true;
                used[6+i] = false;
                ans[count] = ' ';
            }
        }
    }
    return false;
}

int main()
{

    int n;
    char tmp[11];
    cin >> n;
    rep(i,n)
    {
        cin >> tmp;
        usedNames.insert(tmp);
    }
    if (f_find(0,false))
    {
        cout << ans << endl;
    }
    else
        cout << "NO" << endl;
    return 0;
}

0