結果

問題 No.305 鍵(2)
ユーザー LatteIceLatteIce
提出日時 2015-11-28 03:07:44
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 28 ms / 2,000 ms
コード長 966 bytes
コンパイル時間 1,177 ms
コンパイル使用メモリ 64,620 KB
実行使用メモリ 24,348 KB
平均クエリ数 52.15
最終ジャッジ日時 2023-09-23 22:08:13
合計ジャッジ時間 1,833 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
23,484 KB
testcase_01 AC 26 ms
24,348 KB
testcase_02 AC 26 ms
24,348 KB
testcase_03 AC 26 ms
23,940 KB
testcase_04 AC 26 ms
24,036 KB
testcase_05 AC 26 ms
23,376 KB
testcase_06 AC 23 ms
23,556 KB
testcase_07 AC 26 ms
23,364 KB
testcase_08 AC 26 ms
23,964 KB
testcase_09 AC 25 ms
24,288 KB
testcase_10 AC 26 ms
24,048 KB
testcase_11 AC 26 ms
23,376 KB
testcase_12 AC 27 ms
23,580 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;

// Drinking programming is so fun, isn't it?
int main() {
	int pin[10] = { 0 };
	int corrected = -1;

	for (int i = 0; i < 10;i++) {				// for each pin code digit
		for (int j = 0; j < 10;j++) {			// for each numeric
			pin[i] = j;

			// output
			for (int k = 0; k < 10; k++) cout << pin[k]; cout << endl;

			// input
			int responce1;
			string responce2;
			cin >> responce1 >> responce2;

			// check
			if (corrected == -1) corrected = responce1;	// initial round
			if (responce1 == 10 || responce2 == "unlocked") {
				return 0;								// mission completed :D
			} else if (responce1 > corrected) {
				corrected = responce1;
				break;									// to next digit
			} else if (responce1 < corrected) {
				pin[i] = j - 1;
				corrected = responce1 + 1;
				break;									// to next digit
			} else {
				corrected = responce1;
			}
		}
	}
}
0