結果

問題 No.355 数当てゲーム(2)
ユーザー tempura-samatempura-sama
提出日時 2016-05-17 16:12:38
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 28 ms / 2,000 ms
コード長 1,209 bytes
コンパイル時間 992 ms
コンパイル使用メモリ 55,428 KB
実行使用メモリ 24,420 KB
平均クエリ数 5.52
最終ジャッジ日時 2023-09-23 23:53:27
合計ジャッジ時間 4,859 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
24,048 KB
testcase_01 AC 23 ms
23,988 KB
testcase_02 AC 22 ms
24,396 KB
testcase_03 AC 23 ms
23,820 KB
testcase_04 AC 23 ms
23,544 KB
testcase_05 AC 22 ms
23,844 KB
testcase_06 AC 22 ms
24,348 KB
testcase_07 AC 24 ms
24,420 KB
testcase_08 AC 22 ms
23,388 KB
testcase_09 AC 23 ms
24,288 KB
testcase_10 AC 22 ms
23,400 KB
testcase_11 AC 23 ms
24,072 KB
testcase_12 AC 22 ms
23,544 KB
testcase_13 AC 23 ms
23,652 KB
testcase_14 AC 23 ms
23,424 KB
testcase_15 AC 22 ms
24,036 KB
testcase_16 AC 22 ms
24,060 KB
testcase_17 AC 22 ms
24,024 KB
testcase_18 AC 23 ms
23,400 KB
testcase_19 AC 23 ms
23,664 KB
testcase_20 AC 23 ms
23,652 KB
testcase_21 AC 23 ms
24,408 KB
testcase_22 AC 23 ms
23,652 KB
testcase_23 AC 23 ms
23,544 KB
testcase_24 AC 23 ms
23,844 KB
testcase_25 AC 22 ms
23,988 KB
testcase_26 AC 24 ms
23,424 KB
testcase_27 AC 24 ms
24,396 KB
testcase_28 AC 24 ms
23,424 KB
testcase_29 AC 22 ms
23,556 KB
testcase_30 AC 24 ms
23,676 KB
testcase_31 AC 22 ms
23,652 KB
testcase_32 AC 23 ms
23,424 KB
testcase_33 AC 23 ms
23,544 KB
testcase_34 AC 22 ms
23,412 KB
testcase_35 AC 22 ms
23,412 KB
testcase_36 AC 22 ms
23,724 KB
testcase_37 AC 23 ms
23,436 KB
testcase_38 AC 23 ms
23,664 KB
testcase_39 AC 23 ms
24,048 KB
testcase_40 AC 24 ms
24,288 KB
testcase_41 AC 23 ms
23,424 KB
testcase_42 AC 23 ms
23,664 KB
testcase_43 AC 23 ms
23,388 KB
testcase_44 AC 23 ms
24,036 KB
testcase_45 AC 24 ms
23,676 KB
testcase_46 AC 22 ms
24,204 KB
testcase_47 AC 26 ms
23,820 KB
testcase_48 AC 23 ms
23,424 KB
testcase_49 AC 23 ms
23,388 KB
testcase_50 AC 22 ms
24,036 KB
testcase_51 AC 23 ms
23,436 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

list<int*> pt;

void est(const int o[], const int n[], int& x, int& y)
{
	x = y = 0;
	for ( int i = 0; i < 4; i++ ) {
		if ( o[i] == n[i] ) {
			x++;
		}
		else {
			for ( int j = 0; j < 4; j++ ) {
				if ( o[i] == n[j] ) {
					y++;
					break;
				}
			}
		}
	}
}

void io(int n[], int& x, int& y)
{
	cout << n[0] << " " << n[1] << " " << n[2] << " " << n[3] << endl;
	cin >> x >> y;
}

int main()
{
	for ( int i = 0; i < 10; i++ ) {
		for ( int j = 0; j < 10; j++ ) {
			if ( i == j ) continue;
			for ( int k = 0; k < 10; k++ ) {
				if ( i == k || j == k ) continue;
				for ( int l = 0; l < 10; l++ ) {
				if ( i == l || j == l || k == l ) continue;
					int* n = new int[4] { i, j, k, l };
					pt.push_back(n);
				}
			}
		}
	}

	for ( ;; ) {
		int x, y;
		auto it = pt.begin();
		int n[] = { (*it)[0], (*it)[1], (*it)[2], (*it)[3] };
		io(n, x, y);
		if ( x == 4 ) {
			break;
		}
		do {
			int xt, yt;
			int o[] = { (*it)[0], (*it)[1], (*it)[2], (*it)[3] };
			est(*it, n, xt, yt);
			auto t_it = it++;
			if ( x != xt || y != yt ) {
				pt.erase(t_it);
			}
			else {
				int a = 0;
			}
		}
		while ( it != pt.end() );
	}

	return 0;
}
0