結果

問題 No.305 鍵(2)
ユーザー vain0vain0
提出日時 2015-11-27 23:16:10
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,203 bytes
コンパイル時間 556 ms
コンパイル使用メモリ 77,508 KB
実行使用メモリ 24,408 KB
平均クエリ数 92.38
最終ジャッジ日時 2023-09-23 06:48:15
合計ジャッジ時間 3,635 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 25 ms
23,412 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:66:10: warning: ‘mi_d’ may be used uninitialized in this function [-Wmaybe-uninitialized]
   key[i] = mi_d;

ソースコード

diff #

#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <functional>
#include <cmath>
#ifndef ONLINE_JUDGE
# include <complex>
# include <random>
# include <array>
# include <unordered_map>
# define mkt make_tuple
#endif
#ifdef _LOCAL
# include "module/for_local.h"
#else
# define assert(...) ((void)0)
# define ifdebug if (false)
# define echo(...) ((void)0)
#endif
using namespace std;
typedef long long ll; typedef unsigned long long ull;
#define repi(_I, _B, _E) for(int _I = (_B); (_I) < (_E); ++ (_I))
#define rep(_I, _N) for(int _I = 0; (_I) < (_N); ++ (_I))
#define all(_X) (_X).begin(), (_X).end()

string key = "0000000000";

pair<int, bool> query()
{
	cout << key << endl;

	int n;
	static char msg[10] {};
	cin >> n >> msg;
	return { n, ! strcmp(msg, "unlocked") };
}

int main()
{
	int n;
	bool unlocked;

	rep(i, 10)
	{
		int mi = 1<<29;
		char mi_d;
		for ( char d = '0'; d <= '9'; d++ )
		{
			key[i] = d;
			tie(n, unlocked) = query();
			if ( unlocked ) return 0;

			if ( mi >= n ) {
				mi = n;
				mi_d = d;
			}
		}
		key[i] = mi_d;
	}
	return 0;
}
0