Solution -「THUPC 2019」Duckchess
Description
Link.
大模拟是不可能给你概括题意的。
Solution
(据说鸭棋题解用这个标题很吉利)(这里是被点名批评的 长度 19k 的打法)(先说好代码里 Chinglish 满地,尽量不要吐槽吧……)
首先我们不需要仔细阅读每一种棋的判定方法及其走法,写的时候照抄即可。
理一下大体逻辑。首先开一个全局的棋盘 vector<vector<string> > evemap;,一个 over 表示棋局是否结束。
然后是棋手的结构体:
struct chess
{
string color;
string getcolor(int x,int y);
string getchess(int x,int y);
bool outside(int x,int y);
bool exist(int x,int y);
bool thereok(int x,int y);
bool occaptain(int sx,int sy,int tx,int ty);
bool ocguard(int sx,int sy,int tx,int ty);
bool ocelephant(int sx,int sy,int tx,int ty);
bool ochorse(int sx,int sy,int tx,int ty);
bool occar(int sx,int sy,int tx,int ty);
bool ocduck(int sx,int sy,int tx,int ty);
bool ocsoldier(int sx,int sy,int tx,int ty);
string checkgoi();
bool checkove();
void moving(int sx,int sy,int tx,int ty);
string final(string s);
vector<string> movecaptain(int sx,int sy,int tx,int ty);
vector<string> moveguard(int sx,int sy,int tx,int ty);
vector<string> moveelephant(int sx,int sy,int tx,int ty);
vector<string> movehorse(int sx,int sy,int tx,int ty);
vector<string> movecar(int sx,int sy,int tx,int ty);
vector<string> moveduck(int sx,int sy,int tx,int ty);
vector<string> movesoldier(int sx,int sy,int tx,int ty);
vector<string> execute(int sx,int sy,int tx,int ty);
}redplay,blueplay;
string color 表示棋手的颜色。
这里先来解释一下各个函数的含义:
oc-chess和move-chess形式:bool oc-chess(sx,sy,tx,ty):这个表示chess棋从 \((s_{x},s_{y})\) 走到 \((t_{x},t_{y})\) 是否合法。vector<string> move-chess(sx,sy,tx,ty):这个标识chess棋从 \((s_{x},s_{y})\) 走到 \((t_{x},t_{y})\) 最终返回的东西。
其他的一些杂函数:
string getcolor(x,y):棋盘位置 \((x,y)\) 的棋的颜色,如果没有则返回empty。string getchess(x,y):棋盘位置 \((x,y)\) 的棋的棋子类型,如果没有则返回empty。bool outside(int x,int y):\((x,y)\) 是否出界。bool exist(int x,int y):\((x,y)\) 是否存在任意一方的棋子。bool thereok(int x,int y):\((x,y)\) 是否不存在同色棋子且没有出界。string checkgoi():检查是否有将军。(通过遍历棋盘实现)bool checkove():是否有任意一方的将军被吃。void moving(int sx,int sy,int tx,int ty):把 \((s_{x},s_{y})\) 的棋子移到 \((t_{x},t_{y})\)。string final(string s):我棋盘存储棋子的形式是color-chess,这个函数的作用就是转为题目的形式color chess。void execute(sx,sy,tx,ty):处理一次询问。
结构差不多就这里,接下来说一下具体实现。
- 首先用个
void mapinitial()初始化棋盘。 - 然后都询问,处理询问,调用
execute()。 - 输出。
好的我承认这个实现方法特别烂。
/*
function(vector<string>)(with prefix 'move') result:
"invcom": invalid command
"color-chess": the chess(opposite) which is eaten
"beaten": have the Jiangjun been complete
"over": have the game been over
vector[0][1][2][3]
*/
#include<queue>
#include<cstdio>
#include<string>
#include<cstring>
#include<algorithm>
using namespace std;
const int h=10,w=9;
int over;
//string evemap[20][20];
vector<vector<string> > evemap;
void printmap()
{
for(int i=0;i<h;++i)
{
for(int j=0;j<w;++j) printf("%14s",evemap[i][j].c_str()),printf("[%d %d]",i,j);
printf("\n");
}
}
struct chess
{
string color;
string getcolor(int x,int y)
/*
result:
"empty": empty place
"red": red chess
"blue": blue chess
*/
{
string res,s=evemap[x][y];
if(s=="empty") return "empty";
else
{
for(int i=0;i<s.length();++i)
{
if(s[i]=='-') break;
res+=s[i];
}
return res;
}
}
string getchess(int x,int y)
/*
result:
each string has the same meaning as 'evemap'
*/
{
string res,s=evemap[x][y];
if(s=="empty") return "empty";
else
{
int st=0;
for(int i=0;i<s.length();++i)
{
if(st) res+=s[i];
else if(s[i]=='-') st=1;
}
return res;
}
}
bool outside(int x,int y)
{
if(x<0||x>=h||y<0||y>=w) return 1;
else return 0;
}
bool exist(int x,int y)
{
if(getchess(x,y)=="empty") return 0;
else return 1;
}
bool thereok(int x,int y)
/*
result:
1: this place is walkable
0: this place is occupied or (x,y) is out of range
means:
1. isn't out of range
2. (x,y) has no same color chess or is empty
*/
{
if(outside(x,y)) return 0;
else if(evemap[x][y]!="empty"&&getcolor(x,y)==color) return 0;
else return 1;
}
bool occaptain(int sx,int sy,int tx,int ty)
{
if(!thereok(tx,ty)) return 0;
for(int i=-1;i<=1;++i)
{
if(i)
{
if(thereok(sx+i,sy)&&tx==(sx+i)&&ty==sy) return 1;
else if(thereok(sx,sy+i)&&tx==sx&&ty==(sy+i)) return 1;
}
}
return 0;
}
bool ocguard(int sx,int sy,int tx,int ty)
{
if(!thereok(tx,ty)) return 0;
for(int i=-1;i<=1;++i)
{
if(i)
{
if(thereok(sx+i,sy+i)&&tx==(sx+i)&&ty==(sy+i)) return 1;
if(thereok(sx+i,sy-i)&&tx==(sx+i)&&ty==(sy-i)) return 1;
}
}
return 0;
}
bool ocelephant(int sx,int sy,int tx,int ty)
{
if(!thereok(tx,ty)) return 0;
for(int i=-1;i<=1;++i)
{
if(i)
{
for(int j=-1;j<=1;++j)
{
if(j)
{
if(thereok(sx+i,sy+j))
{
if(thereok(sx+(i<<1),sy+(j<<1))&&tx==(sx+(i<<1))&&ty==(sy+(j<<1))) return 1;
}
}
}
}
}
return 0;
}
bool ochorse(int sx,int sy,int tx,int ty)
{
if(!thereok(tx,ty)) return 0;
for(int i=-1;i<=1;++i)
{
if(i)
{
for(int j=-1;j<=1;++j)
{
if(j)
{
// printf("[{%d %d} {%d %d} {%d %d %d}]\n",sx,sy+j,sx+i,sy+(j<<1),outside(sx,sy+j),exist(sx,sy+j),!outside(sx,sy+j)&&!exist(sx,sy+j));
if(!outside(sx+i,sy)&&!exist(sx+i,sy))
{
if(thereok(sx+(i<<1),sy+j)&&tx==(sx+(i<<1))&&ty==(sy+j)) return 1;
}
if(!outside(sx,sy+j)&&!exist(sx,sy+j))
{
if(thereok(sx+i,sy+(j<<1))&&tx==(sx+i)&&ty==(sy+(j<<1))) return 1;
}
}
}
}
}
return 0;
}
bool occar(int sx,int sy,int tx,int ty)
{
if(!thereok(tx,ty)) return 0;
if(sx==tx)
{
int delta;
if(sy<ty) delta=1;
else delta=-1;
for(int j=sy;j^ty;j+=delta)
{
if((j^sy)&&exist(sx,j)) return 0;
}
return 1;
}
else if(sy==ty)
{
int delta;
if(sx<tx) delta=1;
else delta=-1;
for(int i=sx;i^tx;i+=delta)
{
// printf("[{%d %d}]\n",i,sy);
if((i^sx)&&exist(i,sy)) return 0;
}
return 1;
}
else return 0;
}
bool ocduck(int sx,int sy,int tx,int ty)
{
if(!thereok(tx,ty)) return 0;
for(int i=-1;i<=1;++i)
{
if(i)
{
for(int j=-1;j<=1;++j)
{
if(j)
{
if(!outside(sx+(i<<1),sy+j)&&!exist(sx+(i<<1),sy+j)&&!outside(sx+i,sy)&&!exist(sx+i,sy))
{
// printf("[{%d %d} {%d %d} {%d %d} {%d %d} {%d %d} {%d %d}]\n",sx,sy,tx,ty,sx+i,sy,sx+(i<<1),sy+j,sx+((i<<1)+i),sy+(j<<1),thereok(sx+((i<<1)+i),sy+(j<<1)),tx==(sx+((i<<1)+i)&&ty==(sy+(j<<1))));
if(thereok(sx+((i<<1)+i),sy+(j<<1))&&tx==(sx+((i<<1)+i))&&ty==(sy+(j<<1))) return 1;
}
if(!outside(sx+i,sy+(j<<1))&&!exist(sx+i,sy+(j<<1))&&!outside(sx,sy+j)&&!exist(sx,sy+j))
{
if(thereok(sx+(i<<1),sy+((j<<1)+j))&&tx==(sx+(i<<1))&&ty==(sy+((j<<1)+j))) return 1;
}
}
}
}
}
return 0;
}
bool ocsoldier(int sx,int sy,int tx,int ty)
{
if(!thereok(tx,ty)) return 0;
for(int i=-1;i<=1;++i)
{
if(i)
{
if(thereok(sx+i,sy)&&tx==(sx+i)&&ty==sy) return 1;
if(thereok(sx,sy+i)&&tx==sx&&ty==(sy+i)) return 1;
if(thereok(sx+i,sy+i)&&tx==(sx+i)&&ty==(sy+i)) return 1;
if(thereok(sx+i,sy-i)&&tx==(sx+i)&&ty==(sy-i)) return 1;
}
}
return 0;
}
string checkgoi()
/*
result:
"not": Jiangjun didn't happened
"red": the RED general has been Jiangjuned
"blue": the BLUE general has been Jiangjuned
*/
{
if(over) return "not";
for(int i=0;i<h;++i)
{
for(int j=0;j<w;++j)
{
string curcol=getcolor(i,j),curche=getchess(i,j),revcol;
if(curcol=="red") revcol="blue";
else if(curcol=="blue") revcol="red";
else revcol="empty";
if(curche!="empty")
{
if(curche=="captain")
{
for(int k=-1;k<=1;++k)
{
if(k)
{
if(!outside(i+k,j))
{
string nxtcol=getcolor(i+k,j),nxtche=getchess(i+k,j);
if(nxtcol==revcol&&nxtche=="captain") return nxtcol;
}
if(!outside(i,j+k))
{
string nxtcol=getcolor(i,j+k),nxtche=getchess(i,j+k);
if(nxtcol==revcol&&nxtche=="captain") return nxtcol;
}
}
}
}
else if(curche=="guard")
{
for(int k=-1;k<=1;++k)
{
if(k)
{
if(!outside(i+k,j+k))
{
string nxtcol=getcolor(i+k,j+k),nxtche=getchess(i+k,j+k);
if(nxtcol==revcol&&nxtche=="captain") return nxtcol;
}
if(!outside(i+k,j-k))
{
string nxtcol=getcolor(i+k,j-k),nxtche=getchess(i+k,j-k);
if(nxtcol==revcol&&nxtche=="captain") return nxtcol;
}
}
}
}
else if(curche=="elephant")
{
for(int k=-1;k<=1;++k)
{
if(k)
{
for(int l=-1;l<=1;++l)
{
if(l)
{
if(!outside(i+(k<<1),j+(l<<1))&&!exist(i+k,j+l))
{
string nxtcol=getcolor(i+(k<<1),j+(l<<1)),nxtche=getchess(i+(k<<1),j+(l<<1));
if(nxtcol==revcol&&nxtche=="captain") return nxtcol;
}
}
}
}
}
}
else if(curche=="horse")
{
for(int k=-1;k<=1;++k)
{
if(k)
{
for(int l=-1;l<=1;++l)
{
if(l)
{
if(!outside(i+(k<<1),j+l)&&!exist(i+k,j))
{
string nxtcol=getcolor(i+(k<<1),j+l),nxtche=getchess(i+(k<<1),j+l);
if(nxtcol==revcol&&nxtche=="captain") return nxtcol;
}
if(!outside(i+k,j+(l<<1))&&!exist(i,j+l))
{
string nxtcol=getcolor(i+k,j+(l<<1)),nxtche=getchess(i+k,j+(l<<1));
if(nxtcol==revcol&&nxtche=="captain") return nxtcol;
}
}
}
}
}
}
else if(curche=="car")
{
for(int k=i;k<h;++k)
{
if(!outside(k,j))
{
string nxtcol=getcolor(k,j),nxtche=getchess(k,j);
if(nxtche!="empty")
{
if(nxtche=="captain") return nxtcol;
break;
}
}
}
for(int l=j;l<w;++l)
{
if(!outside(i,l))
{
string nxtcol=getcolor(i,l),nxtche=getchess(i,l);
if(nxtche!="empty")
{
if(nxtche=="captain") return nxtcol;
break;
}
}
}
}
else if(curche=="duck")
{
for(int k=-1;k<=1;++k)
{
if(k)
{
for(int l=-1;l<=1;++l)
{
if(l)
{
if(!outside(i+((k<<1)+k),j+(l<<1))&&!exist(i+(k<<1),j+l)&&!exist(i+k,j))
{
string nxtcol=getcolor(i+((k<<1)+k),j+(l<<1)),nxtche=getchess(i+((k<<1)+k),j+(l<<1));
if(nxtcol==revcol&&nxtche=="captain") return nxtcol;
}
if(!outside(i+(k<<1),j+((l<<1)+l))&&!exist(i+k,j+(l<<1))&&!exist(i,j+l))
{
string nxtcol=getcolor(i+(k<<1),j+((l<<1)+l)),nxtche=getchess(i+(k<<1),j+((l<<1)+l));
if(nxtcol==revcol&&nxtche=="captain") return nxtcol;
}
}
}
}
}
}
else if(curche=="soldier")
{
for(int k=-1;k<=1;++k)
{
if(k)
{
if(!outside(i+k,j))
{
string nxtcol=getcolor(i+k,j),nxtche=getchess(i+k,j);
if(nxtcol==revcol&&nxtche=="captain") return nxtcol;
}
if(!outside(i,j+k))
{
string nxtcol=getcolor(i,j+k),nxtche=getchess(i,j+k);
if(nxtcol==revcol&&nxtche=="captain") return nxtcol;
}
if(!outside(i+k,j+k))
{
string nxtcol=getcolor(i+k,j+k),nxtche=getchess(i+k,j+k);
if(nxtcol==revcol&&nxtche=="captain") return nxtcol;
}
if(!outside(i+k,j-k))
{
string nxtcol=getcolor(i+k,j-k),nxtche=getchess(i+k,j-k);
if(nxtcol==revcol&&nxtche=="captain") return nxtcol;
}
}
}
}
}
}
}
return "not";
}
bool checkove()
/*
result:
0: the game isn't over
1: the game is still alive
*/
{
bool red=0,blue=0;
for(int i=0;i<h;++i)
{
for(int j=0;j<w;++j)
{
if(getchess(i,j)=="captain")
{
// printf("[%d %d]\n",i,j);
if(getcolor(i,j)=="red") red=1;
else blue=1;
}
}
}
return !red||!blue;
}
void moving(int sx,int sy,int tx,int ty)
{
evemap[tx][ty]=evemap[sx][sy];
evemap[sx][sy]="empty";
}
string final(string s)
{
if(s=="empty") return "empty";
else
{
for(int i=0;i<s.length();++i)
{
if(s[i]=='-')
{
s[i]=' ';
break;
}
}
return s;
}
}
vector<string> movecaptain(int sx,int sy,int tx,int ty)
{
vector<string> res;
// printf("%s %s\n",getcolor(sx,sy).c_str(),color.c_str());
if(over||!occaptain(sx,sy,tx,ty)||getcolor(sx,sy)!=color)
{
res.push_back("Invalid command");
return res;
}
else
{
string cur,eat,goi,ove,col,lor;
col=getcolor(sx,sy);
lor=getcolor(tx,ty);
cur=getchess(sx,sy);
eat=getchess(tx,ty);
if(lor=="empty") lor="";
if(eat=="empty") eat="NA";
moving(sx,sy,tx,ty);
if(checkgoi()!="not") goi="yes";
else goi="no";
if(checkove())
{
over=1;
ove="yes";
}
else ove="no";
cur=final(cur);
res.push_back(col+" "+cur);
if(lor!="") res.push_back(lor+" "+eat);
else res.push_back(eat);
res.push_back(goi);
res.push_back(ove);
return res;
}
}
vector<string> moveguard(int sx,int sy,int tx,int ty)
{
vector<string> res;
if(over||!ocguard(sx,sy,tx,ty)||getcolor(sx,sy)!=color)
{
res.push_back("Invalid command");
return res;
}
else
{
string cur,eat,goi,ove,col,lor;
col=getcolor(sx,sy);
lor=getcolor(tx,ty);
cur=getchess(sx,sy);
eat=getchess(tx,ty);
if(lor=="empty") lor="";
if(eat=="empty") eat="NA";
moving(sx,sy,tx,ty);
if(checkgoi()!="not") goi="yes";
else goi="no";
if(checkove())
{
over=1;
ove="yes";
}
else ove="no";
cur=final(cur);
res.push_back(col+" "+cur);
if(lor!="") res.push_back(lor+" "+eat);
else res.push_back(eat);
res.push_back(goi);
res.push_back(ove);
return res;
}
}
vector<string> moveelephant(int sx,int sy,int tx,int ty)
{
vector<string> res;
if(over||!ocelephant(sx,sy,tx,ty)||getcolor(sx,sy)!=color)
{
res.push_back("Invalid command");
return res;
}
else
{
string cur,eat,goi,ove,col,lor;
col=getcolor(sx,sy);
lor=getcolor(tx,ty);
cur=getchess(sx,sy);
eat=getchess(tx,ty);
if(lor=="empty") lor="";
if(eat=="empty") eat="NA";
moving(sx,sy,tx,ty);
if(checkgoi()!="not") goi="yes";
else goi="no";
if(checkove())
{
over=1;
ove="yes";
}
else ove="no";
cur=final(cur);
res.push_back(col+" "+cur);
if(lor!="") res.push_back(lor+" "+eat);
else res.push_back(eat);
res.push_back(goi);
res.push_back(ove);
return res;
}
}
vector<string> movehorse(int sx,int sy,int tx,int ty)
{
vector<string> res;
if(over||!ochorse(sx,sy,tx,ty)||getcolor(sx,sy)!=color)
{
res.push_back("Invalid command");
return res;
}
else
{
string cur,eat,goi,ove,col,lor;
col=getcolor(sx,sy);
lor=getcolor(tx,ty);
cur=getchess(sx,sy);
eat=getchess(tx,ty);
if(lor=="empty") lor="";
if(eat=="empty") eat="NA";
moving(sx,sy,tx,ty);
if(checkgoi()!="not") goi="yes";
else goi="no";
if(checkove())
{
over=1;
ove="yes";
}
else ove="no";
cur=final(cur);
res.push_back(col+" "+cur);
if(lor!="") res.push_back(lor+" "+eat);
else res.push_back(eat);
res.push_back(goi);
res.push_back(ove);
return res;
}
}
vector<string> movecar(int sx,int sy,int tx,int ty)
{
vector<string> res;
if(over||!occar(sx,sy,tx,ty)||getcolor(sx,sy)!=color)
{
res.push_back("Invalid command");
return res;
}
else
{
string cur,eat,goi,ove,col,lor;
col=getcolor(sx,sy);
lor=getcolor(tx,ty);
cur=getchess(sx,sy);
eat=getchess(tx,ty);
if(lor=="empty") lor="";
if(eat=="empty") eat="NA";
moving(sx,sy,tx,ty);
if(checkgoi()!="not") goi="yes";
else goi="no";
if(checkove())
{
over=1;
ove="yes";
}
else ove="no";
cur=final(cur);
res.push_back(col+" "+cur);
if(lor!="") res.push_back(lor+" "+eat);
else res.push_back(eat);
res.push_back(goi);
res.push_back(ove);
return res;
}
}
vector<string> moveduck(int sx,int sy,int tx,int ty)
{
vector<string> res;
if(over||!ocduck(sx,sy,tx,ty)||getcolor(sx,sy)!=color)
{
res.push_back("Invalid command");
return res;
}
else
{
string cur,eat,goi,ove,col,lor;
col=getcolor(sx,sy);
lor=getcolor(tx,ty);
cur=getchess(sx,sy);
eat=getchess(tx,ty);
if(lor=="empty") lor="";
if(eat=="empty") eat="NA";
moving(sx,sy,tx,ty);
if(checkgoi()!="not") goi="yes";
else goi="no";
if(checkove())
{
over=1;
ove="yes";
}
else ove="no";
cur=final(cur);
res.push_back(col+" "+cur);
if(lor!="") res.push_back(lor+" "+eat);
else res.push_back(eat);
res.push_back(goi);
res.push_back(ove);
return res;
}
}
vector<string> movesoldier(int sx,int sy,int tx,int ty)
{
vector<string> res;
if(over||!ocsoldier(sx,sy,tx,ty)||getcolor(sx,sy)!=color)
{
res.push_back("Invalid command");
return res;
}
else
{
string cur,eat,goi,ove,col,lor;
col=getcolor(sx,sy);
lor=getcolor(tx,ty);
cur=getchess(sx,sy);
eat=getchess(tx,ty);
if(lor=="empty") lor="";
if(eat=="empty") eat="NA";
moving(sx,sy,tx,ty);
if(checkgoi()!="not") goi="yes";
else goi="no";
if(checkove())
{
over=1;
ove="yes";
}
else ove="no";
cur=final(cur);
res.push_back(col+" "+cur);
if(lor!="") res.push_back(lor+" "+eat);
else res.push_back(eat);
res.push_back(goi);
res.push_back(ove);
return res;
}
}
vector<string> execute(int sx,int sy,int tx,int ty)
{
if(getchess(sx,sy)=="captain") return movecaptain(sx,sy,tx,ty);
else if(getchess(sx,sy)=="guard") return moveguard(sx,sy,tx,ty);
else if(getchess(sx,sy)=="elephant") return moveelephant(sx,sy,tx,ty);
else if(getchess(sx,sy)=="horse") return movehorse(sx,sy,tx,ty);
else if(getchess(sx,sy)=="car") return movecar(sx,sy,tx,ty);
else if(getchess(sx,sy)=="duck") return moveduck(sx,sy,tx,ty);
else if(getchess(sx,sy)=="soldier") return movesoldier(sx,sy,tx,ty);
else return vector<string>({"Invalid command"});
}
}redplay,blueplay;
void mapinitial()
{
evemap.resize(20);
static vector<string> zero({"red-car","red-horse","red-elephant","red-guard","red-captain","red-guard","red-elephant","red-horse","red-car"});
static vector<string> one({"empty","empty","empty","empty","empty","empty","empty","empty","empty"});
static vector<string> two({"red-duck","empty","empty","empty","empty","empty","empty","empty","red-duck"});
static vector<string> three({"red-soldier","empty","red-soldier","empty","red-soldier","empty","red-soldier","empty","red-soldier"});
static vector<string> four({"empty","empty","empty","empty","empty","empty","empty","empty","empty"});
static vector<string> five({"empty","empty","empty","empty","empty","empty","empty","empty","empty"});
static vector<string> six({"blue-soldier","empty","blue-soldier","empty","blue-soldier","empty","blue-soldier","empty","blue-soldier"});
static vector<string> seven({"blue-duck","empty","empty","empty","empty","empty","empty","empty","blue-duck"});
static vector<string> eight({"empty","empty","empty","empty","empty","empty","empty","empty","empty"});
static vector<string> nine({"blue-car","blue-horse","blue-elephant","blue-guard","blue-captain","blue-guard","blue-elephant","blue-horse","blue-car"});
evemap[0]=zero;
evemap[1]=one;
evemap[2]=two;
evemap[3]=three;
evemap[4]=four;
evemap[5]=five;
evemap[6]=six;
evemap[7]=seven;
evemap[8]=eight;
evemap[9]=nine;
for(int i=0;i<evemap.size();++i) evemap[i].resize(20);
}
int main()
{
// freopen("duck.in","r",stdin);
// freopen("own.out","w",stdout);
mapinitial();
redplay.color="red";
blueplay.color="blue";
int q,now=1;
scanf("%d",&q);
// printmap();
for(int i=1;i<=q;++i)
{
int sx,sy,tx,ty;
scanf("%d%d%d%d",&sx,&sy,&tx,&ty);
// printf("{%d %d %d %d}\n",sx,sy,tx,ty);
vector<string> ret;
if(now&1) ret=redplay.execute(sx,sy,tx,ty);
else ret=blueplay.execute(sx,sy,tx,ty);
if(ret[0]=="Invalid command") printf("Invalid command\n");
else
{
printf("%s;%s;%s;%s\n",ret[0].c_str(),ret[1].c_str(),ret[2].c_str(),ret[3].c_str());
if(ret[3]=="yes") over=1;
now++;
}
// if(i>=q-1)
// printmap();
}
return 0;
}
Solution -「THUPC 2019」Duckchess的更多相关文章
- 【题解】#6622. 「THUPC 2019」找树 / findtree(Matrix Tree+FWT)
[题解]#6622. 「THUPC 2019」找树 / findtree(Matrix Tree+FWT) 之前做这道题不理解,有一点走火入魔了,甚至想要一本近世代数来看,然后通过人类智慧思考后发现, ...
- Solution -「CTS 2019」「洛谷 P5404」氪金手游
\(\mathcal{Description}\) Link. 有 \(n\) 张卡牌,第 \(i\) 张的权值 \(w_i\in\{1,2,3\}\),且取值为 \(k\) 的概率正比于 \ ...
- Solution -「JSOI 2019」「洛谷 P5334」节日庆典
\(\mathscr{Description}\) Link. 给定字符串 \(S\),求 \(S\) 的每个前缀的最小表示法起始下标(若有多个,取最小的). \(|S|\le3\time ...
- Solution -「CCO 2019」「洛谷 P5532」Sirtet
\(\mathcal{Description}\) Link. 在一个 \(n\times m\) 的网格图中,每个格子上是空白 . 或沙子 #,四联通的沙子会连成一个整体.令此时所有沙子块同 ...
- Solution -「ZJOI 2019」「洛谷 P5326」开关
\(\mathcal{Description}\) Link. 有 \(n\) 个开关,初始时所有开关的状态为 \(0\).给定开关的目标状态 \(s_1,s_2,\cdots,s_n\).每 ...
- Solution -「JOISC 2019」「LOJ #3036」指定城市
\(\mathcal{Description}\) Link. 给定一棵含 \(n\) 个结点的树,双向边权不相同.\(q\) 次询问,每次询问在树上标记 \(e\) 个点,标记的价值为所有趋 ...
- Solution -「ROI 2019」「LOJ #3192」课桌
\(\mathcal{Description}\) Link. 原题意足够简洁啦.( \(\mathcal{Solution}\) 乍一看比较棘手,但可以从座位的安排方式入手,有结论: ...
- Solution -「HNOI 2019」「洛谷 P5293」白兔之舞
\(\mathcal{Description}\) Link. 不想概括题意.jpg \(\mathcal{Solution}\) 定义点集 \(S_c=\{(u,v)|v=c\}\):第 ...
- 【LOJ6620】「THUPC 2019」不等式 / inequality(线段树)
点此看题面 大致题意: 给你两个长度为\(n\)的数组\(a_i\)和\(b_i\),定义\(f_k(x)=\sum_{i=1}^k|a_ix+b_i|\),对于\(k=1\sim n\)的每个\(f ...
- 「THUPC 2019」不等式 / inequality
https://loj.ac/problem/6620 高中数学好题.. |kx+b|的函数图像很直观,直接考虑函数图像: 一定只有一段极小值点! 这个点就是最小值了 特点:斜率为0! 而且发现,如果 ...
随机推荐
- K8S | 核心原理分析
目录 一.背景 二.持续集成 三.K8S架构 1.核心组件 2.分层结构 3.核心能力 3.1 发现与负载 3.2 调度 3.3 自动伸缩 四.应用案例 1.服务部署 2.交互流程 五.参考源码 整体 ...
- 2023-06-20:给定一个长度为N的数组arr,arr[i]表示宝石的价值 你在某天遇到X价值的宝石, X价值如果是所有剩余宝石价值中的最小值,你会将该宝石送人 X价值如果不是所有剩余宝石价值中的
2023-06-20:给定一个长度为N的数组arr,arr[i]表示宝石的价值 你在某天遇到X价值的宝石, X价值如果是所有剩余宝石价值中的最小值,你会将该宝石送人 X价值如果不是所有剩余宝石价值中的 ...
- 微服务bug之:openFeign远程调用返回类型转换异常
楼主是在使用easyexcel导出的时候,获取数据出现这个错误,因为Spring底层是这样处理的使用LinkedhashMap来承接查询结果,导致转换异常 public List<NeedAll ...
- JVM中的-Xms 、-Xmx 参数该如何设置
在 Java 虚拟机(JVM)中,-Xms 和 -Xmx 都是用来设置 JVM 堆内存大小的参数.其中,-Xms 用于设置 JVM 启动时分配的初始堆内存大小,而 -Xmx 用于设置 JVM 堆内存的 ...
- Unity的AssetPostprocessor之Model:深入解析与实用案例 2
Unity AssetPostprocessor中Model相关函数的实际应用 Unity AssetPostprocessor是Unity引擎中的一个重要功能,它可以在导入资源时自动一些脚本,以便对 ...
- 为什么 kubelet 不使用容器化部署?
每日一问系列 为什么 kubelet 不使用容器化部署? 通过脚本(shell/ansible 等)在节点上部署 kubelet 服务时,涉及 kubelet 进程 service 启动配置.证书等, ...
- 【Redis】八股文(一)
什么是Redis 基于key-value存储结构的NoSQL数据库 提供了String, Map, Set, ZSet, List等多种数据类型 功能丰富:支持发布订阅模式,能够为数据设置过期时间,能 ...
- 永远拥抱开放生态 | Metaworld2.0能力发布
回看过去的二十年,互联网从门户网站发布信息,用户只能获取阅读:到如今的人人生产内容,再借助各类平台设施上传投递给其他用户.这个过程中,内容生产力的分布从集中转为分散,恰似互联网从1.0走向2.0的 ...
- matlab 整数提升为正整数幂
matlab 整数提升为正整数幂 在使用matlab 的gui界面绘制时报的错误, 是因为之前数据有非double类型的数据,但是有的数据看起来确实是double类型的,但是程序还是报错跑不下去 解决 ...
- 图技术在 LLM 下的应用:知识图谱驱动的大语言模型 Llama Index
LLM 如火如荼地发展了大半年,各类大模型和相关框架也逐步成型,可被大家应用到业务实际中.在这个过程中,我们可能会遇到一类问题是:现有的哪些数据,如何更好地与 LLM 对接上.像是大家都在用的知识图谱 ...