結果

問題 No.233 めぐるはめぐる (3)
ユーザー Kmcode1Kmcode1
提出日時 2015-06-26 22:40:49
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,697 bytes
コンパイル時間 1,049 ms
コンパイル使用メモリ 110,764 KB
実行使用メモリ 13,720 KB
最終ジャッジ日時 2023-09-22 00:52:57
合計ジャッジ時間 5,879 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 151 ms
13,032 KB
testcase_01 AC 83 ms
9,664 KB
testcase_02 AC 36 ms
6,496 KB
testcase_03 AC 100 ms
10,344 KB
testcase_04 WA -
testcase_05 AC 189 ms
13,520 KB
testcase_06 AC 177 ms
13,420 KB
testcase_07 AC 228 ms
13,520 KB
testcase_08 AC 223 ms
13,716 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 89 ms
9,752 KB
testcase_13 AC 158 ms
13,280 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<cctype>
#include<cstdlib>
#include<algorithm>
#include<bitset>
#include<vector>
#include<list>
#include<deque>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<ctime>
#include<complex>
#include<functional>
#include<climits>
#include<cassert>
#include<iterator>
#include<unordered_map>
using namespace std;

int n;
set<string> s;
int main(){
	cin >> n;
	for (int i = 0; i < n; i++){
		string k;
		cin >> k;
		s.insert(k);
	}
	string t = "inabameguru";
	vector<char> a;
	vector<char> b;
	a.clear();
	b.clear();
	for (int i = 0; i < t.size(); i++){
		if (i % 2){
			b.push_back(t[i]);
		}
		else{
			a.push_back(t[i]);
		}
	}
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	do{
		sort(b.begin(), b.end());
		do{
			string k;
			k.clear();
			for (int i = 0; i < a.size() + b.size()-1; i++){  //i,i+1=a
				k.clear();
				int ind = 0;
				int indd = 0;
				bool flag = false;
				if (i != 0){
					flag = true;
				}
				for (int j = 0; j < a.size() + b.size(); j++){
					if (flag){
						k.push_back(b[indd]);
						indd++;
					}
					else{
						k.push_back(a[ind]);
						ind++;
					}
					if (j == i - 1){
						flag = false;
						continue;
					}
					if (j == i){
						flag = false;
						continue;
					}
					flag ^= 1;
				}
				if (s.count(k)){
					continue;
				}
				if (find(a.begin(), a.end(), k.back()) == a.end()){
					continue;
				}
				cout << k << endl;
				return 0;
			}
		} while (next_permutation(b.begin(), b.end()));
	} while (next_permutation(a.begin(), a.end()));
	puts("NO");
	return 0;
}
0