結果

問題 No.305 鍵(2)
ユーザー femtofemto
提出日時 2016-08-12 00:15:42
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 31 ms / 2,000 ms
コード長 774 bytes
コンパイル時間 622 ms
コンパイル使用メモリ 77,320 KB
実行使用メモリ 24,360 KB
平均クエリ数 87.62
最終ジャッジ日時 2023-09-24 00:25:48
合計ジャッジ時間 2,067 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
23,460 KB
testcase_01 AC 28 ms
24,360 KB
testcase_02 AC 28 ms
23,604 KB
testcase_03 AC 28 ms
23,784 KB
testcase_04 AC 26 ms
24,360 KB
testcase_05 AC 27 ms
23,988 KB
testcase_06 AC 25 ms
24,060 KB
testcase_07 AC 28 ms
23,844 KB
testcase_08 AC 28 ms
23,472 KB
testcase_09 AC 28 ms
24,060 KB
testcase_10 AC 28 ms
23,700 KB
testcase_11 AC 27 ms
24,348 KB
testcase_12 AC 27 ms
24,096 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: 関数 ‘int main()’ 内:
main.cpp:37:30: 警告: ‘maxj’ may be used uninitialized [-Wmaybe-uninitialized]
   37 |                 ans[i] = '0' + maxj;
      |                          ~~~~^~~~~~
main.cpp:25:24: 備考: ‘maxj’ はここで定義されています
   25 |                 int n, maxj, maxn = -1;
      |                        ^~~~

ソースコード

diff #

#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <iomanip>
using namespace std;
template<typename T> void setmin(T& a, T b) { a = min(a, b); }
template<typename T> void setmax(T& a, T b) { a = max(a, b); }

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	string ans = "0000000000", res;
	int pn;

	cout << ans << endl;
	cout.flush();
	cin >> pn >> res;
	if(res == "unlocked") return 0;

	for(int i = 0; i < 10; i++) {
		int n, maxj, maxn = -1;
		for(int j = 0; j < 10; j++) {
			ans[i] = '0' + j;
			cout << ans << endl;
			cout.flush();
			cin >> n >> res;
			if(res == "unlocked") return 0;
			if(maxn == -1 || maxn < n) {
				maxj = j;
				maxn = n;
			}
		}
		ans[i] = '0' + maxj;
	}
}
0