結果

問題 No.2768 Password Crack
ユーザー テナガザル
提出日時 2024-06-13 20:19:26
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 99 ms / 2,000 ms
コード長 496 bytes
コンパイル時間 1,367 ms
コンパイル使用メモリ 104,224 KB
実行使用メモリ 25,472 KB
平均クエリ数 955.37
最終ジャッジ日時 2024-06-13 20:19:32
合計ジャッジ時間 5,771 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 29
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;
int main()
{
	int n;
	cin >> n;
	string ans(n, 'a');
	for (int i = 0; i < n; ++i)
	{
		int bs;
		cout << "? " << ans << endl;
		cin >> bs;
		for (char j = 'b'; j <= 'z'; ++j)
		{
			ans[i] = j;
			if (j == 'z') break;
			cout << "? " << ans << endl;
			int tmp;
			cin >> tmp;
			if (bs > tmp)
			{
				ans[i] = 'a';
				break;
			}
			else if (bs < tmp) break;
		}
	}
	cout << "! " << ans << endl;
}
0