結果

問題 No.355 数当てゲーム(2)
ユーザー はむこはむこ
提出日時 2016-09-02 08:40:57
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 24 ms / 2,000 ms
コード長 1,200 bytes
コンパイル時間 1,521 ms
コンパイル使用メモリ 154,464 KB
実行使用メモリ 24,408 KB
平均クエリ数 25.40
最終ジャッジ日時 2023-09-24 00:29:19
合計ジャッジ時間 5,231 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 24 ms
23,376 KB
testcase_01 AC 21 ms
24,000 KB
testcase_02 AC 20 ms
23,796 KB
testcase_03 AC 20 ms
23,472 KB
testcase_04 AC 22 ms
23,316 KB
testcase_05 AC 23 ms
23,976 KB
testcase_06 AC 20 ms
23,328 KB
testcase_07 AC 21 ms
23,340 KB
testcase_08 AC 19 ms
23,568 KB
testcase_09 AC 20 ms
23,328 KB
testcase_10 AC 20 ms
23,316 KB
testcase_11 AC 21 ms
23,364 KB
testcase_12 AC 20 ms
23,772 KB
testcase_13 AC 21 ms
24,264 KB
testcase_14 AC 21 ms
23,796 KB
testcase_15 AC 21 ms
24,276 KB
testcase_16 AC 19 ms
23,328 KB
testcase_17 AC 20 ms
23,892 KB
testcase_18 AC 22 ms
24,324 KB
testcase_19 AC 21 ms
23,592 KB
testcase_20 AC 20 ms
23,628 KB
testcase_21 AC 20 ms
23,568 KB
testcase_22 AC 21 ms
23,472 KB
testcase_23 AC 20 ms
23,472 KB
testcase_24 AC 22 ms
23,784 KB
testcase_25 AC 20 ms
23,772 KB
testcase_26 AC 20 ms
24,300 KB
testcase_27 AC 20 ms
23,340 KB
testcase_28 AC 20 ms
23,784 KB
testcase_29 AC 20 ms
23,988 KB
testcase_30 AC 21 ms
23,484 KB
testcase_31 AC 22 ms
23,976 KB
testcase_32 AC 20 ms
24,000 KB
testcase_33 AC 21 ms
24,252 KB
testcase_34 AC 20 ms
24,180 KB
testcase_35 AC 19 ms
24,408 KB
testcase_36 AC 20 ms
23,376 KB
testcase_37 AC 21 ms
23,604 KB
testcase_38 AC 19 ms
23,976 KB
testcase_39 AC 21 ms
24,336 KB
testcase_40 AC 22 ms
23,484 KB
testcase_41 AC 21 ms
24,300 KB
testcase_42 AC 20 ms
23,340 KB
testcase_43 AC 20 ms
23,328 KB
testcase_44 AC 20 ms
23,292 KB
testcase_45 AC 20 ms
23,616 KB
testcase_46 AC 21 ms
23,376 KB
testcase_47 AC 19 ms
24,312 KB
testcase_48 AC 19 ms
23,316 KB
testcase_49 AC 24 ms
23,580 KB
testcase_50 AC 21 ms
23,328 KB
testcase_51 AC 23 ms
23,592 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

void output(vector<int> &v) { for (int i = 0; i < v.size(); i++) printf("%s%d", i ? " " : "", v[i]); printf("\n"); }

pair<int, int> query(vector<int> a) {
	for (int i = 0; i < 4; i++) cout << (i ? " " : "") << a[i];
	cout << endl;

	int x, y;
	cin >> x >> y;

	if (x == 4) exit(0);

	return make_pair(x, y);
}

int sum(pair<int, int> p) {
	return p.first + p.second;
}

int main() {
	int d1 = sum(query({ 0, 1, 2, 3 }));
	int d2 = sum(query({ 6, 7, 8, 9 }));

	vector<int> e1(10, -10), e2(10, -10);
	e1[3] = 0;
	for (int i = 4; i <= 9; i++) {
		e1[i] = sum(query({ 0, 1, 2, i })) - d1;
	}

	e2[6] = 0;
	for (int i = 0; i <= 5; i++) {
		e2[i] = sum(query({ i, 7, 8, 9 })) - d2;
	}

	int mx1 = *max_element(e1.begin(), e1.end());
	int mx2 = *max_element(e2.begin(), e2.end());

	vector<int> cand;
	
	for (int i = 4; i <= 9; i++) {
		if (e1[i] == mx1) cand.push_back(i);
	}

	for (int i = 0; i <= 5; i++) {
		if (e2[i] == mx2) cand.push_back(i);
	}

	sort(cand.begin(), cand.end());
	cand.erase(unique(cand.begin(), cand.end()), cand.end());

	do {
		if (query(cand).first == 4) {
			return 0;
		}
	} while (next_permutation(cand.begin(), cand.end()));
}
0