結果

問題 No.233 めぐるはめぐる (3)
ユーザー syoken_desukasyoken_desuka
提出日時 2015-06-30 01:02:29
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 2,655 bytes
コンパイル時間 716 ms
コンパイル使用メモリ 88,432 KB
実行使用メモリ 9,596 KB
最終ジャッジ日時 2023-09-22 04:35:45
合計ジャッジ時間 6,568 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 WA -
testcase_12 WA -
testcase_13 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘bool f(int)’:
main.cpp:81:27: warning: converting to non-pointer type ‘char’ from NULL [-Wconversion-null]
             tmp[length] = NULL;
                           ^~~~
main.cpp:94:27: warning: converting to non-pointer type ‘char’ from NULL [-Wconversion-null]
             tmp[length] = NULL;
                           ^~~~

ソースコード

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;

static bool usedSiin[6];
static bool usedBoin[5];
static int cooo;
char boin[5];
char siin[6];
char tmp[11];

vector<string> listm;

bool f(int length)
{
    cout << cooo << endl;
    cooo++;
    if (length == 11)
    {
        bool isSinBefore = false;
        for (int i = 0; i < 11; i++)
        {
            if (   tmp[i] == 'n' 
                || tmp[i] == 'b'
                || tmp[i] == 'm'
                || tmp[i] == 'g'
                || tmp[i] == 'r')
            {
                if (isSinBefore)
                {
                    return false;
                }
                else
                {
                    isSinBefore = true;
                }
            }
            else
                isSinBefore = false;
        }
        string comparer(tmp);
        for (int i = 0; i < listm.size(); i++)
        {
            if ( comparer.compare(listm[i]) != 0)
            {
                return false;
            }
        }
        return true;
    }
    //next node search
    for (int i = 0; i < 6; i++) // boin
    {
        if (!usedBoin[i])
        {
            tmp[length] = boin[i];
            usedBoin[i] = true;
            if(f(length + 1)) return true;
            usedBoin[i] = false;
            tmp[length] = NULL; 
            return false;

        }
    }
    for (int i = 0; i < 5; i++) // siin
    {
        if (!usedSiin[i])
        {
            tmp[length] = siin[i];
            usedSiin[i] = true;
            if(f(length + 1)) return true;
            usedSiin[i] = false;
            tmp[length] = NULL;  
        }
    }
    return false;
}


int main()
{
    boin[0]='i';
    boin[1]='a';
    boin[2]='a';
    boin[3]='e';
    boin[4]='u';
    boin[5]='u'; 
    siin[0]='n';
    siin[1]='b';
    siin[2]='m';
    siin[3]='g';
    siin[4]='r';

    cooo = 0;
    int n ;
    cin >> n;
    string sss;
    rep(i,n)
    {
        cin >> sss;
        listm.push_back(sss);
    }
    char ans[11];
    if (f(0))
    {
        cout << ans << endl;
    }
    else
    {
       cout << "No" << endl;
    }
    return 0;

}

0