結果
| 問題 | 
                            No.233 めぐるはめぐる (3)
                             | 
                    
| コンテスト | |
| ユーザー | 
                             syoken_desuka
                         | 
                    
| 提出日時 | 2015-07-02 22:45:59 | 
| 言語 | C++11(廃止可能性あり)  (gcc 13.3.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 2,110 bytes | 
| コンパイル時間 | 721 ms | 
| コンパイル使用メモリ | 92,684 KB | 
| 実行使用メモリ | 8,576 KB | 
| 最終ジャッジ日時 | 2024-07-07 22:24:12 | 
| 合計ジャッジ時間 | 6,742 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge3 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 1 WA * 2 | 
| other | WA * 11 | 
コンパイルメッセージ
main.cpp: In function ‘bool f_find(int)’:
main.cpp:73:26: warning: converting to non-pointer type ‘char’ from NULL [-Wconversion-null]
   73 |             ans[count] = NULL;
      |                          ^~~~
main.cpp:87:26: warning: converting to non-pointer type ‘char’ from NULL [-Wconversion-null]
   87 |             ans[count] = NULL;
      |                          ^~~~
            
            ソースコード
#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)
{
    if (count == 11)
    {
        return judge();
    }
    rep(i,6)
    {
        if (!used[i])
        {
            ans[count] = nameChars1[i];
            used[i] = true;
            if (f_find(count+1))
            {
                return true;
            }
            used[i] = false;
            ans[count] = NULL;
        }
    }
    rep(i,5)
    {           
        if (!used[6+i])
        {
            ans[count] = nameChars2[i];
            used[6+i] = true;
            if (f_find(count+1))
            {
                return true;
            }
            used[6+i] = false;
            ans[count] = NULL;
        }
    }
    return false;
}
int main()
{
    int n;
    char tmp[11];
    cin >> n;
    rep(i,n)
    {
        cin >> tmp;
        usedNames.insert(tmp);
    }
    if (f_find(0))
    {
        cout << ans << endl;
    }
    else
        cout << "NO" << endl;
    return 0;
}
            
            
            
        
            
syoken_desuka