题意:。。。
析:随机判断就即可,每次把不正确的删除,经过几次后就基本剩不下了。
代码如下:
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <cstring>
#include <set>
#include <queue>
#include <algorithm>
#include <vector>
#include <map>
#include <cctype>
#include <cmath>
#include <stack>
#include <sstream>
#include <unordered_map>
#include <unordered_set>
#define debug() puts("++++");
#define freopenr freopen("in.txt", "r", stdin)
#define freopenw freopen("out.txt", "w", stdout)
using namespace std; typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> P;
const int INF = 0x3f3f3f3f;
const LL LNF = 1LL << 60;
const double inf = 0x3f3f3f3f3f3f;
const double PI = acos(-1.0);
const double eps = 1e-8;
const int maxn = 100 + 5;
const int mod = 2000;
const int dr[] = {-1, 1, 0, 0};
const int dc[] = {0, 0, 1, -1};
const char *de[] = {"0000", "0001", "0010", "0011", "0100", "0101", "0110", "0111", "1000", "1001", "1010", "1011", "1100", "1101", "1110", "1111"};
int n, m;
const int mon[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
const int monn[] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
inline bool is_in(int r, int c){
return r >= 0 && r < n && c >= 0 && c < m;
}
bool use[15]; P query(const string &s){
cout << s << endl;
int a, b;
cin >> a >> b;
return P(a, b);
} void dfs(int d, string s, vector<string> &v){
if(4 == d){
v.push_back(s);
return ;
}
for(int i = 0; i < 10; ++i) if(!use[i]){
use[i] = true;
dfs(d+1, s + (char)('0' + i), v);
use[i] = false;
}
} bool judge(const string &s1, const string &s2, P &p){
int cnt1 = 0;
for(int i = 0; i < 4; ++i)
if(s1[i] == s2[i]) ++cnt1;
int cnt2 = 0;
for(int i = 0; i < 4; ++i)
for(int j = 0; j < 4; ++j)
if(s2[i] == s1[j]){ ++cnt2; break; }
return cnt1 == p.first && (cnt2 - cnt1 == p.second);
} vector<string> solve(P &p, vector<string> &v){
vector<string> tmp;
for(int i = 1; i < v.size(); ++i)
if(judge(v[0], v[i], p)) tmp.push_back(v[i]);
return tmp;
} #include <ctime>
int main(){
fflush(stdout);
srand(2333333);
vector<string> v;
memset(use, 0, sizeof use);
dfs(0, "", v);
while(true){
random_shuffle(v.begin(), v.end());
P tmp = query(v[0]);
if(tmp.first == 4) break;
v = solve(tmp, v);
}
return 0;
}
CodeForces 753C Interactive Bulls and Cows (Hard)的更多相关文章
-
【Codeforces 63C】Bulls and Cows
[链接] 我是链接,点我呀:) [题意] 给你一个长度为4的数字序列(每个数字都在0~9之间,且不重复出现) 现在让你猜这个长度为4的序列是什么. 猜了之后对方会告诉有几个数字是位置和数字都正确的(猜 ...
-
[LeetCode] Bulls and Cows 公母牛游戏
You are playing the following Bulls and Cows game with your friend: You write a 4-digit secret numbe ...
-
LeetCode 299 Bulls and Cows
Problem: You are playing the following Bulls and Cows game with your friend: You write down a number ...
-
[Leetcode] Bulls and Cows
You are playing the following Bulls and Cows game with your friend: You write a 4-digit secret numbe ...
-
Bulls and Cows
You are playing the following Bulls and Cows game with your friend: You write down a number and ask ...
-
299.	Bulls and Cows
题目: You are playing the following Bulls and Cows game with your friend: You write down a number and ...
-
Java [Leetcode 229]Bulls and Cows
题目描述: You are playing the following Bulls and Cows game with your friend: You write down a number an ...
-
[LeetCode299]Bulls and Cows
题目: You are playing the following Bulls and Cows game with your friend: You write down a number and ...
-
Bulls and Cows leetcode
You are playing the following Bulls and Cows game with your friend: You write down a number and ask ...
随机推荐
-
APP漏洞扫描用地址空间随机化
APP漏洞扫描用地址空间随机化 前言 我们在前文<APP漏洞扫描器之本地拒绝服务检测详解>了解到阿里聚安全漏洞扫描器有一项静态分析加动态模糊测试的方法来检测的功能,并详细的介绍了它在针对本 ...
-
【康拓展开】及其在求全排列第k个数中的应用
题目:给出n个互不相同的字符, 并给定它们的相对大小顺序,这样n个字符的所有排列也会有一个顺序. 现在任给一个排列,求出在它后面的第i个排列.这是一个典型的康拓展开应用,首先我们先阐述一下什么是康拓展 ...
-
POI XSSF与HSSF的 使用区别
首次写博客,希望能坚持下去,一点一滴的积累,内容不多也不深,但愿我的分享,能帮助和我一样的新人们解决问题 最近给项目中添加了一个导入excel表格的功能,然而在功能开发结束后测试,发现报错. 报错信息 ...
-
sqoop的merge和eval 工具
1.sqoop的merge的工具 sqoop merge 可以将hdfs上的两个文件进行合并,在increment import的过程中经常会用到,如incremenet import将数据导入到hd ...
-
在php4下可用,简单的php数组转成json格式,
function array_to_json( $array ){ if( !is_array( $array ) ){ return false; } $ ...
-
AES加密 16进制与二进制转换
import java.security.Key; import javax.crypto.Cipher; import javax.crypto.KeyGenerator; import javax ...
-
一个模拟时钟的时间选择器 ClockPicker
最近开发的一个模拟时钟的时间选择器 ClockPicker,用于 Bootstrap,或者单独作为一个 jQuery 插件. 源代码托管在 GitHub 上: ClockPicker 最近项目中需要用 ...
-
Honkly分享链接集总篇
VC6.0 Filetool Honkly版 http://pan.baidu.com/s/1bnentr5 密码:15eq,解压密码:honkly VC6.0 Filetool 官方 ...
-
[Swift]LeetCode274.H指数 | H-Index
Given an array of citations (each citation is a non-negative integer) of a researcher, write a funct ...
-
P2858 [USACO06FEB]奶牛零食Treats for the Cows
P2858 [USACO06FEB]奶牛零食Treats for the Cows区间dp,级像矩阵取数, f[i][i+l]=max(f[i+1][i+l]+a[i]*(m-l),f[i][i+l- ...