自己写了一个交互库的板子,放在这里供大家参考
#include<vector>
#include<chrono>
#include<random>
#include<iostream>
using namespace std;
vector<string>now,tmp;
mt19937 rnd(chrono::system_clock::now().time_since_epoch().count());
inline vector<string>get(){
const int N=10,mod=2;
//mod为1时所有基因型都为Aa
//mod为2时基因型只存在AA和Aa
//mod为3时都可能存在
//N表示要加入的基因型的数量
const char s[3][3]={"Aa","AA","aa"};
vector<string>res;
for(int i=N;i;i--)
res.push_back(s[rnd()%mod]);
return res;
}inline char query(const int k){
return now[k-1][0];
}inline void cross(int i,int j){
string s;
s+=now[i-1][rnd()%2];
s+=now[j-1][rnd()%2];
if(s[0]>s[1]) swap(s[0],s[1]);
now.push_back(s);
}
//在这下面放你写好的代码
//如果你的程序能够正确求解答案
//那么程序会输出Accepted!否则就是Wrong Answer!
int main(){
now=tmp=get();
if(tmp==guess(now.size()))
cout<<"Accepted!";
else cout<<"Wrong Answer!";
return 0;
}
另外关于本题的实现,有以下几个注意事项:
1.头文件和using namespace std一定都要写!!!
2.guess函数不要声明成内联函数,否则你会得到compile error的结果。