結果

問題 No.233 めぐるはめぐる (3)
ユーザー parukiparuki
提出日時 2016-08-18 16:25:10
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 422 ms / 1,000 ms
コード長 1,434 bytes
コンパイル時間 1,773 ms
コンパイル使用メモリ 177,168 KB
実行使用メモリ 13,824 KB
最終ジャッジ日時 2024-04-25 08:55:18
合計ジャッジ時間 6,590 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 90 ms
13,312 KB
testcase_01 AC 58 ms
9,984 KB
testcase_02 AC 30 ms
6,656 KB
testcase_03 AC 62 ms
10,496 KB
testcase_04 AC 416 ms
13,824 KB
testcase_05 AC 216 ms
13,696 KB
testcase_06 AC 209 ms
13,824 KB
testcase_07 AC 416 ms
13,696 KB
testcase_08 AC 422 ms
13,696 KB
testcase_09 AC 6 ms
5,376 KB
testcase_10 AC 7 ms
5,376 KB
testcase_11 AC 7 ms
5,376 KB
testcase_12 AC 57 ms
10,112 KB
testcase_13 AC 88 ms
13,568 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;

string nstr(){
    static const int MAX_LEN = 101;
    static char res_[MAX_LEN];
    scanf("%s",res_);
    return string(res_);
}

const string meg = "inabameguru", bo = "iaeu", si = "nbmgr";
const int M = sz(meg);

int main(){
    set<char> st(si.begin(), si.end());
    int N;
    while(cin >> N){
        set<string> in;
        rep(i, N){
            in.insert(nstr());
        }
        string s = meg;
        sort(all(s));
        bool ok = false;
        do{
            if(st.count(s.back()))continue;
            bool rom = true;
            rep(i, M - 1)if(st.count(s[i]) && st.count(s[i + 1])){
                rom = false;
                break;
            }
            if(!rom)continue;
            if(in.count(s) == 0){
                cout << s << endl;
                ok = true;
                break;
            }
        } while(next_permutation(all(s)));
        if(!ok)cout << "NO" << endl;
    }
}
0