結果

問題 No.355 数当てゲーム(2)
ユーザー kapokapo
提出日時 2016-05-07 14:59:54
言語 C90
(gcc 11.4.0)
結果
AC  
実行時間 29 ms / 2,000 ms
コード長 1,318 bytes
コンパイル時間 304 ms
コンパイル使用メモリ 25,672 KB
実行使用メモリ 24,408 KB
平均クエリ数 25.46
最終ジャッジ日時 2023-09-23 23:51:02
合計ジャッジ時間 4,350 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
24,228 KB
testcase_01 AC 27 ms
24,336 KB
testcase_02 AC 26 ms
24,048 KB
testcase_03 AC 25 ms
24,240 KB
testcase_04 AC 25 ms
23,652 KB
testcase_05 AC 27 ms
23,436 KB
testcase_06 AC 25 ms
24,228 KB
testcase_07 AC 25 ms
23,436 KB
testcase_08 AC 25 ms
23,688 KB
testcase_09 AC 25 ms
23,652 KB
testcase_10 AC 25 ms
24,408 KB
testcase_11 AC 25 ms
23,676 KB
testcase_12 AC 25 ms
23,592 KB
testcase_13 AC 26 ms
23,652 KB
testcase_14 AC 24 ms
24,288 KB
testcase_15 AC 25 ms
23,448 KB
testcase_16 AC 25 ms
23,436 KB
testcase_17 AC 25 ms
23,400 KB
testcase_18 AC 24 ms
23,400 KB
testcase_19 AC 26 ms
23,460 KB
testcase_20 AC 25 ms
23,664 KB
testcase_21 AC 24 ms
23,844 KB
testcase_22 AC 25 ms
24,012 KB
testcase_23 AC 25 ms
24,300 KB
testcase_24 AC 25 ms
23,592 KB
testcase_25 AC 26 ms
23,688 KB
testcase_26 AC 25 ms
23,448 KB
testcase_27 AC 24 ms
23,448 KB
testcase_28 AC 26 ms
23,448 KB
testcase_29 AC 25 ms
24,336 KB
testcase_30 AC 25 ms
23,592 KB
testcase_31 AC 24 ms
23,712 KB
testcase_32 AC 25 ms
23,400 KB
testcase_33 AC 24 ms
24,060 KB
testcase_34 AC 25 ms
24,336 KB
testcase_35 AC 25 ms
24,324 KB
testcase_36 AC 25 ms
23,568 KB
testcase_37 AC 26 ms
24,312 KB
testcase_38 AC 25 ms
24,048 KB
testcase_39 AC 25 ms
23,688 KB
testcase_40 AC 25 ms
24,288 KB
testcase_41 AC 25 ms
24,048 KB
testcase_42 AC 24 ms
23,460 KB
testcase_43 AC 26 ms
24,312 KB
testcase_44 AC 24 ms
23,556 KB
testcase_45 AC 25 ms
23,400 KB
testcase_46 AC 24 ms
23,448 KB
testcase_47 AC 24 ms
24,240 KB
testcase_48 AC 24 ms
24,288 KB
testcase_49 AC 25 ms
23,412 KB
testcase_50 AC 25 ms
24,036 KB
testcase_51 AC 25 ms
24,060 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>

int b[4], p[4], p2[4], used[4], f=0;

void perm( int node)
{
	if( node == 4 ) {
		if( !f ) {
			int i, x, y;
			printf("%d %d %d %d\n", b[ p[0] ], b[ p[1] ], b[ p[2] ], b[ p[3] ]);
			fflush(stdout);
			scanf("%d %d", &x, &y);
			if( x == 4 ) f = 1;
		}
	} else {
		int i;
		for( i = 0; i < 4; i++) {
			if( !used[i] ) {
				used[i] = 1;
				p[node] = i;
				perm(node+1);
				used[i] = 0;
			}
		}
	}
}

int main(void)
{
	int i, j, k, a[4]={9,0,1,2}, x, y, xy=0, bxy=0, bcnt=0;

	while( bcnt != 4) {

		printf("%d %d %d %d\n", a[0], a[1], a[2], a[3]);
		fflush(stdout);
		scanf("%d %d", &x, &y);
		if(x == 4) return 0;

		xy = x+y;
		for( j = 0; j < bcnt; j++) {
			for( k = 0; k < 4; k++) if( a[k] == b[j] ) xy--;
		}

		int cnt = 0, s[10]={};
		while( cnt < 10 ) {
			for( i = 0; i < 4; i++) {
				a[i] = (cnt+i) % 10;
			}

			printf("%d %d %d %d\n", a[0], a[1], a[2], a[3]);
			fflush(stdout);
			scanf("%d %d", &x, &y);
			if(x == 4) return 0;

			bxy = xy;
			xy = x+y;
			for( j = 0; j < bcnt; j++) {
				for( k = 0; k < 4; k++) if( a[k] == b[j] ) xy--;
			}

			if(  xy > bxy ) {
				s[ (cnt+3) % 10] = 1;
			} else if( xy < bxy ) {
				s[ (cnt+9) % 10] = 1;
			}
			cnt++;
		}

		for( i = 0; i < 10; i++) {
			if( s[i] ) {
				b[bcnt] = i;
				bcnt++;
			}
		}
	}

	perm(0);

	return 0;
}
0