結果

問題 No.355 数当てゲーム(2)
ユーザー naimonon77naimonon77
提出日時 2016-09-04 12:28:27
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 84 ms / 2,000 ms
コード長 2,291 bytes
コンパイル時間 996 ms
コンパイル使用メモリ 97,232 KB
実行使用メモリ 24,420 KB
平均クエリ数 15.75
最終ジャッジ日時 2023-09-24 00:30:40
合計ジャッジ時間 7,619 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 76 ms
23,604 KB
testcase_01 AC 75 ms
23,520 KB
testcase_02 AC 67 ms
24,276 KB
testcase_03 AC 70 ms
24,000 KB
testcase_04 AC 69 ms
23,484 KB
testcase_05 AC 67 ms
23,712 KB
testcase_06 AC 72 ms
24,084 KB
testcase_07 AC 72 ms
23,952 KB
testcase_08 AC 70 ms
23,472 KB
testcase_09 AC 84 ms
24,060 KB
testcase_10 AC 73 ms
23,472 KB
testcase_11 AC 70 ms
23,940 KB
testcase_12 AC 72 ms
24,084 KB
testcase_13 AC 70 ms
23,364 KB
testcase_14 AC 69 ms
24,108 KB
testcase_15 AC 71 ms
24,216 KB
testcase_16 AC 81 ms
24,312 KB
testcase_17 AC 80 ms
24,096 KB
testcase_18 AC 84 ms
23,448 KB
testcase_19 AC 71 ms
24,324 KB
testcase_20 AC 70 ms
23,604 KB
testcase_21 AC 69 ms
23,448 KB
testcase_22 AC 80 ms
24,192 KB
testcase_23 AC 74 ms
23,604 KB
testcase_24 AC 76 ms
23,928 KB
testcase_25 AC 69 ms
24,072 KB
testcase_26 AC 77 ms
23,520 KB
testcase_27 AC 69 ms
24,372 KB
testcase_28 AC 69 ms
24,312 KB
testcase_29 AC 70 ms
23,604 KB
testcase_30 AC 70 ms
23,988 KB
testcase_31 AC 68 ms
23,520 KB
testcase_32 AC 76 ms
23,952 KB
testcase_33 AC 68 ms
24,420 KB
testcase_34 AC 75 ms
24,096 KB
testcase_35 AC 73 ms
23,712 KB
testcase_36 AC 76 ms
23,592 KB
testcase_37 AC 73 ms
23,508 KB
testcase_38 AC 82 ms
23,616 KB
testcase_39 AC 76 ms
23,520 KB
testcase_40 AC 72 ms
23,976 KB
testcase_41 AC 72 ms
24,216 KB
testcase_42 AC 76 ms
23,976 KB
testcase_43 AC 76 ms
23,892 KB
testcase_44 AC 75 ms
24,048 KB
testcase_45 AC 72 ms
23,616 KB
testcase_46 AC 79 ms
23,712 KB
testcase_47 AC 71 ms
24,264 KB
testcase_48 AC 74 ms
23,628 KB
testcase_49 AC 80 ms
23,544 KB
testcase_50 AC 76 ms
23,604 KB
testcase_51 AC 72 ms
23,616 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#define REP(i,a,b) for(i=a;i<b;++i)
#define rep(i,n) REP(i,0,n)
#define ll long long
#define ull unsigned ll
typedef long double ld;
#define ALL(a) begin(a),end(a)
#define ifnot(a) if(not a)
#define dump(x)  cerr << #x << " = " << (x) << endl
using namespace std;

// #define int ll
bool test = 0;
int dx[] = { 0,1,0,-1 };
int dy[] = { 1,0,-1,0 };
#define INF (1 << 28)
ull mod = (int)1e9 + 7;
//.....................
#define MAX (int)1e6 + 5

ll pow(ll a, ll b) {
	ll i;
	ll ans = 1;
	rep(i, b) {
		ans *= a;
	}
	return ans;
}

signed main(void) {
	ll i, j, k, l;
	vector<string> ans_group;
	rep(i, 10000) {
		bool visited[10] = {};
		rep(j, 4) {
			ll j_node = (i % pow((ll)10, j + 1)) / pow((ll)10, j);
			if (visited[j_node]) break;
			visited[j_node] = true;
		}
		if (j != 4) continue;
		// printf("%04d\n",i);]
		char s[20];
		sprintf(s, "%04d", i);
		string str = s;
		ans_group.push_back(str);
	}
	// rep(i,ans_group.size()){
	// 	cout << ans_group[i] << endl;
	// }
	srand(time(NULL));
	string ans = "9280";
	while (ans_group.size() > 1) {
		/*if (binary_search(ALL(ans_group), ans)) {
			rep(i, 4) cerr << ans[i];
			cerr << "found"<< endl;
		}
		else cerr << "not found" << endl;
		dump(ans_group.size());*/
		ll query_num = rand() % ans_group.size();
		string query = ans_group[query_num];
		ll x, y;
		rep(i, 3) cout << query[i] << " ";
		cout << query[i] << endl;
		cin >> x >> y;
		if (x == 4) return 0;
		rep(i, ans_group.size()) {
			string target = ans_group[i];
			bool erase = false;
			ll cnt1 = 0, cnt2 = 0;
			rep(j, 4) {
				if (target[j] == query[j]) cnt1++;
			}
			if (cnt1 < x) erase = true;
			rep(j, 4) rep(k, 4) {
				if (target[j] == query[k]) {
					cnt2++;
					break;
				}
			}
			if (cnt2 < x + y) erase = true;

			if (erase) {
				ans_group.erase(ans_group.begin() + i);
				i--;
			}
		}
	}

	rep(i, 3) cout << ans_group[0][i] << " ";
	cout << ans_group[0][i] << endl;
	return 0;
}
0