結果

問題 No.305 鍵(2)
ユーザー femtofemto
提出日時 2016-08-12 00:24:11
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 28 ms / 2,000 ms
コード長 686 bytes
コンパイル時間 656 ms
コンパイル使用メモリ 77,112 KB
実行使用メモリ 24,384 KB
平均クエリ数 87.62
最終ジャッジ日時 2023-09-24 00:26:16
合計ジャッジ時間 1,855 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <iomanip>
using namespace std;

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;
	}

	cout << ans << endl;
	cout.flush();
}
0