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! 而且发现,如果 ...
随机推荐
- Microsoft R 和 Open Source R,哪一个才最适合你?
由于微信不允许外部链接,你需要点击文章尾部左下角的 "阅读原文",才能访问文中链接. R 是一个开源统计软件,在分析领域普及的非常快. 在过去几年中,无论业务规模如何,很多公司都采 ...
- Adobe 构建 IDP 之路的经验与教训
在过去的25年多时间里,我创建了软件组件和分布式框架,建立并领导了相关团队.近几年我致力于推动 Adobe 服务开发.部署和管理系统的开发人员生产力. 抽象陷阱 在云时代早期,Adobe 的每个团队都 ...
- CentOS7环境编译python3.9版本pjsua
环境:CentOS 7.6_x64 Python版本 :3.9.12 pjsip版本:2.13 一.背景描述 pjsip地址:https://www.pjsip.org/ GitHub地址:https ...
- [转载]C++ 入门教程(41课时) - 阿里云大学
C++ 教程 C++ 是一种中级语言,它是由 Bjarne Stroustrup 于 1979 年在贝尔实验室开始设计开发的.C++ 进一步扩充和完善了 C 语言,是一种面向对象的程序设计语言.C++ ...
- WPF入门教程系列二十八 ——DataGrid使用示例MVVM模式(6)
WPF入门教程系列目录 WPF入门教程系列二--Application介绍 WPF入门教程系列三--Application介绍(续) WPF入门教程系列四--Dispatcher介绍 WPF入门教程系 ...
- Nashorn引擎导致metaspace oom
从报错内容很清楚是Metaspace区域oom了 大部分情况下,程序运行中不会出现过多的类加载数量的变动,先导入dump文件检查是否有异常的classLoader或者有异常动态生成的cla ...
- MODBUS RTU转 EtherNet/IP 网关连接森兰变频器与欧姆龙系统通讯
捷米特JM-EIP-RTU(Modbus转Ethernet/Ip)网关,用于将多个 MODBUS 从站设备接入 ETHERNET/IP 主站网络,实现 MODBUS 转 ETHERNET/IP 功 ...
- 记一次.Net分布式事务死锁现象以及解决方法
在本文中,将介绍一次遇到的.Net分布式事务死锁现象以及解决方法.我们将首先了解事务框架的构成,然后分析导致死锁的代码,最后提出解决方法. 事务框架 本次开发框架JMSFramework将分布式事务划 ...
- 《Effective C++ 改善程序与设计的55个具体做法》读书笔记
1 .让自己习惯C++ 条款01 视C++为一个语言联邦 C Object-Oriented C++ Template C++ STL C++高效编程守则视情况而变化,取决于你使用C++的哪一部分. ...
- 当cmd运行python无法显示中文报错 SyntaxError: Non-UTF-8 code starting with 时
报错图片: 解决方法: 在python的脚本开头加上 再运行后