結果

問題 No.701 ひとりしりとり
ユーザー misora192misora192
提出日時 2020-05-16 08:17:10
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 129 ms / 2,000 ms
コード長 603 bytes
コンパイル時間 3,665 ms
コンパイル使用メモリ 174,100 KB
実行使用メモリ 84,984 KB
最終ジャッジ日時 2023-10-21 19:34:13
合計ジャッジ時間 3,364 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 3 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 3 ms
4,348 KB
testcase_10 AC 15 ms
11,444 KB
testcase_11 AC 129 ms
84,984 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i=(0);i<(n);i++)

using namespace std;

typedef long long ll;

int n;

void dfs(string s){
	n--;
	if(n == 0){
		cout << "an" << endl;
		exit(0);
	}

	rep(i, 26){
		cout << "a" << s << "a" << endl;
		s.push_back('a' + i);
		dfs(s);
		s.pop_back();
	}
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);

	cin >> n;
	queue<string> q;
	q.push("");
	n--;
	while(n > 0){
		n--;
		string s = q.front();
		q.pop();
		cout << "a" << s << "a" << "\n";

		rep(i, 26){
			s.push_back('a' + i);
			q.push(s);
			s.pop_back();
		}
	}

	cout << "an" << endl;
}
0