結果

問題 No.305 鍵(2)
ユーザー KKT89KKT89
提出日時 2020-06-09 03:00:41
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 26 ms / 2,000 ms
コード長 636 bytes
コンパイル時間 638 ms
コンパイル使用メモリ 81,636 KB
実行使用メモリ 24,336 KB
平均クエリ数 52.15
最終ジャッジ日時 2023-09-24 02:39:08
合計ジャッジ時間 1,730 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 24 ms
23,640 KB
testcase_01 AC 21 ms
23,700 KB
testcase_02 AC 20 ms
24,336 KB
testcase_03 AC 22 ms
23,676 KB
testcase_04 AC 22 ms
24,048 KB
testcase_05 AC 22 ms
23,376 KB
testcase_06 AC 19 ms
23,412 KB
testcase_07 AC 21 ms
24,012 KB
testcase_08 AC 26 ms
24,324 KB
testcase_09 AC 24 ms
23,652 KB
testcase_10 AC 21 ms
24,096 KB
testcase_11 AC 23 ms
23,568 KB
testcase_12 AC 22 ms
23,652 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
using namespace std;
typedef long long int ll;

string s;
int x;

void ask(string s){
	cout << s << endl;
	string t; 
	cin >> x >> t;
	if(t=="unlocked")exit(0);
}

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	s="";
	for(int i=0;i<10;i++){
		s+='0';
	}
	int id=0;
	while(1){
		ask(s);
		int xx=x;
		s[id]='1';
		ask(s);
		if(x==xx){
			for(int i=2;i<=9;i++){
				s[id]=(char)('0'+i);
				ask(s);
				if(x>xx){
					id++;
					break;
				}
			}
		}
		else if(xx>x){
			s[id]='0';
			id++;
		}
		else{
			s[id]='1';
			id++;
		}
	}
}
0