結果

問題 No.355 数当てゲーム(2)
ユーザー E31415926
提出日時 2016-04-09 15:24:21
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 24 ms / 2,000 ms
コード長 917 bytes
コンパイル時間 698 ms
コンパイル使用メモリ 58,360 KB
実行使用メモリ 25,464 KB
平均クエリ数 36.58
最終ジャッジ日時 2024-07-16 23:37:03
合計ジャッジ時間 4,428 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 52
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<algorithm>
using namespace std;

int main()
{
	int n[4], x, y, i, j, k, l, kakcnt = 0, kakutei[4];
	for (i = 0; i < 10; i++) {
		n[0] = i;
		j = 0; k = 1; l = 0;
		while (j < 9) {
			while (k <= 3) {
				if (j != i) {
					n[k] = j;
					j++; k++;
				}
				else j++;
				if (j > 9)break;
			}
			cout << n[0] << " " << n[1] << " " << n[2] << " " << n[3] << endl << flush;
			cin >> x >> y;
			if (x == 4)return 0;
			l += x + y;
			if (l > 4) {
				kakutei[kakcnt] = i;
				kakcnt++;
				break;
			}
			k = 1;
		}
		if (kakcnt >= 4)break;
	}
	cout << kakutei[0] << " " << kakutei[1] << " " << kakutei[2] << " " << kakutei[3] << endl << flush;
	cin >> x >> y;
	if (x == 4)return 0;
	while (next_permutation(kakutei, kakutei + 4)) {
		cout << kakutei[0] << " " << kakutei[1] << " " << kakutei[2] << " " << kakutei[3] << endl << flush;
		cin >> x >> y;
		if (x == 4)return 0;
	}
	return 0;
}
0