結果

問題 No.305 鍵(2)
ユーザー KKT89
提出日時 2020-06-09 03:00:41
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 36 ms / 2,000 ms
コード長 636 bytes
コンパイル時間 851 ms
コンパイル使用メモリ 78,804 KB
最終ジャッジ日時 2025-01-11 00:19:48
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 13
権限があれば一括ダウンロードができます

ソースコード

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