結果

問題 No.355 数当てゲーム(2)
ユーザー kotamanegikotamanegi
提出日時 2017-01-04 00:14:06
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 31 ms / 2,000 ms
コード長 2,796 bytes
コンパイル時間 1,099 ms
コンパイル使用メモリ 89,004 KB
実行使用メモリ 24,348 KB
平均クエリ数 5.52
最終ジャッジ日時 2023-09-24 00:49:07
合計ジャッジ時間 5,657 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
23,628 KB
testcase_01 AC 26 ms
24,036 KB
testcase_02 AC 26 ms
23,532 KB
testcase_03 AC 26 ms
23,976 KB
testcase_04 AC 26 ms
23,364 KB
testcase_05 AC 27 ms
23,628 KB
testcase_06 AC 26 ms
23,808 KB
testcase_07 AC 27 ms
23,964 KB
testcase_08 AC 27 ms
23,988 KB
testcase_09 AC 27 ms
23,640 KB
testcase_10 AC 27 ms
23,400 KB
testcase_11 AC 26 ms
24,024 KB
testcase_12 AC 25 ms
24,216 KB
testcase_13 AC 26 ms
23,388 KB
testcase_14 AC 26 ms
23,652 KB
testcase_15 AC 26 ms
24,336 KB
testcase_16 AC 26 ms
23,520 KB
testcase_17 AC 26 ms
23,412 KB
testcase_18 AC 26 ms
23,664 KB
testcase_19 AC 27 ms
23,400 KB
testcase_20 AC 26 ms
23,412 KB
testcase_21 AC 26 ms
23,976 KB
testcase_22 AC 26 ms
24,324 KB
testcase_23 AC 26 ms
23,532 KB
testcase_24 AC 26 ms
23,808 KB
testcase_25 AC 26 ms
23,628 KB
testcase_26 AC 26 ms
23,796 KB
testcase_27 AC 26 ms
24,228 KB
testcase_28 AC 26 ms
23,640 KB
testcase_29 AC 25 ms
23,820 KB
testcase_30 AC 26 ms
23,820 KB
testcase_31 AC 26 ms
24,336 KB
testcase_32 AC 25 ms
23,364 KB
testcase_33 AC 26 ms
23,628 KB
testcase_34 AC 26 ms
24,312 KB
testcase_35 AC 25 ms
23,628 KB
testcase_36 AC 25 ms
23,808 KB
testcase_37 AC 26 ms
23,520 KB
testcase_38 AC 26 ms
24,228 KB
testcase_39 AC 26 ms
23,628 KB
testcase_40 AC 26 ms
24,348 KB
testcase_41 AC 26 ms
23,412 KB
testcase_42 AC 26 ms
23,508 KB
testcase_43 AC 26 ms
23,352 KB
testcase_44 AC 26 ms
23,808 KB
testcase_45 AC 27 ms
23,352 KB
testcase_46 AC 26 ms
23,796 KB
testcase_47 AC 27 ms
23,640 KB
testcase_48 AC 26 ms
24,048 KB
testcase_49 AC 26 ms
23,880 KB
testcase_50 AC 26 ms
23,388 KB
testcase_51 AC 25 ms
23,988 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream> 
#include<map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
using namespace std;
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)
#define LONG_INF 100000000000000
int not_used[10][10][10][10] = {};
pair<int, int> hit(int a, int b, int c, int d, int e, int f, int g, int h) {
	int burrow = 0, just = 0;
	if (a == e) just++;
	if (b == f) just++;
	if (c == g) just++;
	if (d == h) just++;
	vector<int> w, q;
	w.push_back(a);
	w.push_back(b);
	w.push_back(c);
	w.push_back(d);
	q.push_back(e);
	q.push_back(f);
	q.push_back(g);
	q.push_back(h);
	for (int i = 0;i < 4;++i) {
		for (int t = 0;t < 4;++t) {
			if (i != t) {
				if (w[i] == q[t]) burrow++;
			}
		}
	}
	return make_pair(just, burrow);
}
int input(int a, int b, int real, int c, int d, int e, int f) {
	int copy_used[10][10][10][10] = {};
	REP(i, 10) {
		REP(q, 10) {
			REP(j, 10) {
				REP(t, 10) {
					copy_used[i][q][j][t] = not_used[i][q][j][t];
				}
			}
		}
	}
	int cnt = 0;
	for (int i = 0;i < 10;++i) {
		for (int q = 0;q < 10;++q) {
			for (int j = 0;j < 10;++j) {
				for (int t = 0;t < 10;++t) {
					if (copy_used[i][q][j][t] == false) {
						pair<int, int> hoge = hit(i, q, j, t, c, d, e, f);
						if (hoge.first != a || hoge.second != b) {
							cnt++;
							copy_used[i][q][j][t] = true;
						}
					}
				}
			}
		}
	}
	if (real == true) {
		REP(i, 10) {
			REP(q, 10) {
				REP(j, 10) {
					REP(t, 10) {
						not_used[i][q][j][t] = copy_used[i][q][j][t];
					}
				}
			}
		}
	}
	return cnt;
}
int output(int a, int b, int c, int d) {
	cout << a <<" " <<  b <<" " <<  c <<" "<< d << endl;
	fflush(stdout);
	int e, f;
	cin >> e >> f;
	input(e, f, 1, a, b, c, d);
	if (e == 4) {
		return 1;
	}
	else return 0;
}
int cal_solve() {
	while (true) {
		int a, b, c, d;
		for (a = 0;a < 10;++a) {
			for (b = 0;b < 10;++b) {
				for (c = 0;c < 10;++c) {
					for (d = 0;d < 10;++d) {
						if (not_used[a][b][c][d] == false) {
							int poper = output(a, b, c, d);
							if (poper == 1) return 0;
							goto ok;
						}
					}
				}
			}
		}
	ok:;
	}
}
int main() {
	REP(i, 10) {
		REP(q, 10) {
			REP(j, 10) {
				REP(t, 10) {
					not_used[i][q][j][t] = true;
				}
			}
		}
	}
	REP(i, 10) {
		REP(q, 10) {
			if (i != q) {
				REP(j, 10) {
					if (j != i&&j != q) {
						REP(t, 10) {
							if (t != i&&t != q && t != j) {
								not_used[i][q][j][t] = false;
							}
						}
					}
				}
			}
		}
	}
	cal_solve();
	return 0;
}
0