首页 > > 详细

解析Python、数据结构讲解、讲解留学生Matlab编程、C/C++讲解

#include
#include
#include
#include
#include
#include
#include
#include
#include
using namespace std;
inline int min(int a, int b) {return a b ? a : b;}
inline double min(double a, double b) {return a b ? a : b;}
#define Lim 15
const double eps = 1e-4;
struct point {
int x,y;
double v;
point () {}
point (int a, int b, double c) {x = a, y = b, v = c;}
bool operator a.v;
}
} tmp[23][233];
double Src[Lim + 1];
int G[Lim + 1][Lim + 1],cnt[3];
double t1[Lim + 1][Lim + 1], t2[Lim + 1][Lim + 1], (*att)[Lim + 1] = t1, (*dfn)[Lim + 1] = t2;
string myData;
char tt[Lim * Lim];
void printBoard() {
myData += "+ 010203040506070809101112131415\n";
for (int i = 1; i = 4 j 1e8) return 1e20;
else if (dfn[i][j] > 1e8) return -1e20;
if (!G[i][j]) {
tmp[dep][++tot].x = i;
tmp[dep][tot].y = j;
tmp[dep][tot].v = att[i][j] + dfn[i][j];
}
}
nth_element(tmp[dep] + 1, tmp[dep] + min(tot, X), tmp[dep] + tot + 1);
sort(tmp[dep] + 1, tmp[dep] + min(tot, X) + 1);
for (int i = 1; i = beta) return val;
alpha = max(alpha, val);
}
return alpha;
}
int now, ene, First;
point work() {
int stp = min(X, cnt[1] * 3);
check(now, ene);
int tot = 0;
for (int i = 1; i " + to_string(tmp[Lim][i].x) + " " + to_string(tmp[Lim][i].y) + "\n";
update(tmp[Lim][i].x, tmp[Lim][i].y, ene, now, 0);
if (pos - eps > ma) {
ma = pos;
x = tmp[Lim][i].x, y = tmp[Lim][i].y;
}
}
return point(x, y, 0);
}
#ifdef _BOTZONE_ONLINE
#include "jsoncpp/json.h"
int tot = 0;
void placeAt(int x, int y, int c) {
if (x < 0) return;
G[x + 1][y + 1] = c; cnt[c]++;
}
Json::Reader reader;
Json::Value input;
int A, B;
void read() {
string str;
getline(cin, str);
reader.parse(str, input);
int turnID = input["responses"].size();
for (int i = 0; i < turnID; i++) {
placeAt(input["requests"][i]["x"].asInt(), input["requests"][i]["y"].asInt(),2);
placeAt(input["responses"][i]["x"].asInt(), input["responses"][i]["y"].asInt(),1);
}
placeAt(input["requests"][turnID]["x"].asInt(), input["requests"][turnID]["y"].asInt(),2);
if (tot1) {
First=0;now=2;ene=1;
}
else {
First=1;now=1;ene=2;
}
A = cnt[1], B = cnt[2];
cnt[0] = Lim * Lim - cnt[1] - cnt[2];
}
Json::Value Position(int x,int y) {
Json::Value action;
action["x"] = x-1;
action["y"] = y-1;
return action;
}
void print(int x,int y) {
Json::Value ret;
// myData = "---- " + to_string(A + B) + " ----\n" + myData + "\n";
ret["response"] = Position(x,y);
// if (A + B < 3) ret["globaldata"] = myData;
// else ret["globaldata"] = input["globaldata"].asString() + myData;
Json::FastWriter writer;
cout << writer.write(ret) << endl;
}
#else
void read() {
freopen("board.in","r",stdin);
scanf("%d",now);
ene=3-now;
//printf("[%d %d]\n", now, ene);
for (int i=1;i<=15;i++) {
for (int j=1;j<=15;j++) {
int ch=getchar();
while (ch<'0') ch=getchar();
G[i][j]=ch-'0';
cnt[G[i][j]]++;
}
}
freopen("/dev/tty", "r", stdin);
}
void print(int x, int y) {
// cout << myData << endl;
freopen("decision.out","w",stdout);
printf("%d %d\n", x, y);
fclose(stdin);
fclose(stdout);
}
#endif
int main() {
for (int i = 0; i < 5; i++) Src[i] = pow(10, i);
Src[2] *= 2.501;
Src[5] = 1e10;
read();
if (cnt[0] == Lim * Lim) {
print((Lim + 1) / 2, (Lim + 1) / 2);
return 0;
}
if (cnt[1]==cnt[2]) First=1;
else First=0;
point p = work();
print(p.x, p.y);
return 0;
}
 

联系我们
  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-21:00
  • 微信:codinghelp
热点标签

联系我们 - QQ: 99515681 微信:codinghelp
程序辅导网!