結果

問題 No.355 数当てゲーム(2)
ユーザー kapokapo
提出日時 2016-05-07 12:48:46
言語 C90
(gcc 11.4.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,291 bytes
コンパイル時間 366 ms
コンパイル使用メモリ 25,896 KB
実行使用メモリ 35,784 KB
最終ジャッジ日時 2023-09-23 23:50:58
合計ジャッジ時間 7,370 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
testcase_49 -- -
testcase_50 -- -
testcase_51 -- -
権限があれば一括ダウンロードができます

ソースコード

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] ]);
			scanf("%d %d", &x, &y);
			if( x == 4 ) {
				f = 1;
				int j;
				for( j = 0; j < 4; j++) {
					p2[j] = p[j];
				}
			}
		}
	} 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]);
		scanf("%d %d", &x, &y);
		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]);
			scanf("%d %d", &x, &y);

			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