結果

問題 No.2768 Password Crack
ユーザー kotatsugame
提出日時 2024-05-31 21:43:29
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 100 ms / 2,000 ms
コード長 674 bytes
コンパイル時間 684 ms
コンパイル使用メモリ 66,008 KB
実行使用メモリ 25,476 KB
平均クエリ数 885.00
最終ジャッジ日時 2024-12-20 22:58:03
合計ジャッジ時間 4,366 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 29
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<cassert>
using namespace std;
int ask(string T)
{
	cout<<"? "<<T<<endl;
	int r;cin>>r;
	return r;
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int N;cin>>N;
	string T(N,'a');
	int base=ask(T);
	for(int i=0;i<N;i++)
	{
		T[i]='b';
		int now=ask(T);
		assert(abs(base-now)<=1);
		if(base>now)
		{
			T[i]='a';
			continue;
		}
		if(base<now)
		{
			base=now;
			continue;
		}
		bool fn=false;
		for(char c='c';c<='y';c++)
		{
			T[i]=c;
			int now=ask(T);
			assert(base<=now&&now<=base+1);
			if(base<now)
			{
				base=now;
				fn=true;
				break;
			}
		}
		if(!fn)
		{
			T[i]='z';
			base++;
		}
	}
	cout<<"! "<<T<<endl;
}
0