QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#399791 | #2821. 鸭棋 | ucup-team1251 | WA | 0ms | 3716kb | C++20 | 6.9kb | 2024-04-26 17:50:43 | 2024-04-26 17:50:44 |
Judging History
answer
#include<bits/stdc++.h>
#define lowbit(x) (x&(-x))
#define ll long long
#define int long long
#define rep(x,a,b) for(int x=a;x<=b;x++)
#define pre(x,a,b) for(int x=a;x>=b;x--)
// #define endl "\n"
#define pb push
#define pii pair<ll,ll>
#define psi pair<string, ll>
#define de cout<<1;
#define mem(a,x) memset(a,x,sizeof a)
#define ls u << 1
#define rs u << 1 | 1
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
// static char buf[100000],*pa=buf,*pd=buf;
// #define gc pa==pd&&(pd=(pa=buf)+fread(buf,1,100000,stdin),pa==pd)?EOF:*pa++
// inline int read()
// {
// register int x(0);register char c(gc);
// while(c<'0'||c>'9')c=gc;
// while(c>='0'&&c<='9')x=(x<<1)+(x<<3)+(c^48),c=gc;
// return x;
// }
const int mod1 = 998244353;
const int mod2=1e9+7;
const int N = 1e6 + 60;
int n, m, fff;
int mp[20][20];
map<int,string>name;
set<pii>re,bl;
int dd(int x)
{
if(x>0)return 1;
else return -1;
}
void init()
{
name[1]="car";
name[2]="horse";
name[3]="elephant";
name[4]="guard";
name[5]="captain";
name[6]="duck";
name[7]="soldier";
mp[1][1]=1;//che
mp[1][2]=2;//ma
mp[1][3]=3;//xiang
mp[1][4]=4;//shi
mp[1][5]=5;//wang
mp[1][6]=4;
mp[1][7]=3;
mp[1][8]=2;
mp[1][9]=1;
mp[3][1]=6;//ya
mp[3][9]=6;
mp[4][1]=7;//bin
mp[4][3]=7;
mp[4][5]=7;
mp[4][7]=7;
mp[4][9]=7;
re.insert({1,1});
re.insert({1,2});
re.insert({1,3});
re.insert({1,4});
re.insert({1,5});
re.insert({1,6});
re.insert({1,7});
re.insert({1,8});
re.insert({1,9});
re.insert({3,1});
re.insert({3,9});
re.insert({4,1});
re.insert({4,3});
re.insert({4,5});
re.insert({4,7});
re.insert({4,9});
mp[10][1]=11;//che
mp[10][2]=12;//ma
mp[10][3]=13;//xiang
mp[10][4]=14;//shi
mp[10][5]=15;//wang
mp[10][6]=14;
mp[10][7]=13;
mp[10][8]=12;
mp[10][9]=11;
mp[8][1]=16;//ya
mp[8][9]=16;
mp[7][1]=17;//bin
mp[7][3]=17;
mp[7][5]=17;
mp[7][7]=17;
mp[7][9]=17;
bl.insert({10,1});
bl.insert({10,2});
bl.insert({10,3});
bl.insert({10,4});
bl.insert({10,5});
bl.insert({10,6});
bl.insert({10,7});
bl.insert({10,8});
bl.insert({10,9});
bl.insert({8,1});
bl.insert({8,9});
bl.insert({7,1});
bl.insert({7,3});
bl.insert({7,5});
bl.insert({7,7});
bl.insert({7,9});
}
bool wang(int sx ,int sy ,int fx,int fy)
{
if(mp[fx][fy] && mp[fx][fy]/10 == mp[sx][sy]/10)return 0;
if(abs(fx-sx) + abs(fy-sy) == 1)return 1;
return 0;
}
bool shi(int sx,int sy,int fx,int fy)
{
if(mp[fx][fy] && mp[fx][fy]/10 == mp[sx][sy]/10)return 0;
if(abs(fx-sx)==1 && abs(fy-sy)==1)return 1;
return 0;
}
bool xiang(int sx,int sy,int fx,int fy)
{
if(mp[fx][fy] && mp[fx][fy]/10 == mp[sx][sy]/10)return 0;
if(abs(sx-fx)==2 && abs(sy-fy)==2)
{
int xx=dd(fx-sx);
int yy=dd(fy-sy);
if(!mp[sx+xx][sy+yy])return 1;
}
return 0;
}
bool ma(int sx,int sy,int fx,int fy)
{
if(mp[fx][fy] && mp[fx][fy]/10 == mp[sx][sy]/10)return 0;
if(abs(sx-fx)+abs(sy-fy)==3 && abs(sx-fx) && abs(sy-fy))
{
int xx=(abs(fx-sx)-1)*dd(fx-sx);
int yy=(abs(fy-sy)-1)*dd(fy-sy);
if(!mp[sx+xx][sy+yy])return 1;
}
return 0;
}
bool che(int sx,int sy,int fx,int fy)
{
if(mp[fx][fy] && mp[fx][fy]/10 == mp[sx][sy]/10)return 0;
if(sx!=fx && sy!=fy)return 0;
if(sx == fx)
{
for(int i=sy+dd(fy-sy);i!=fy;i+=dd(fy-sy))
{
if(mp[sx][i])return 0;
}
return 1;
}else
{
for(int i=sx+dd(fx-sx);i!=fx;i+=dd(fx-sx))
{
if(mp[i][sy])return 0;
}
return 1;
}
}
bool ya(int sx,int sy,int fx,int fy)
{
if(mp[fx][fy] && mp[fx][fy]/10 == mp[sx][sy]/10)return 0;
if(abs(fx-sx)==2 && abs(fy-sy)==3)
{
int xx=dd(fx-sx);
int yy=dd(fy-sy);
if(!mp[sx+xx][sy+yy*2])
{
if(!mp[sx][sy+yy])
{
return 1;
}
}
}
return 0;
}
bool bing(int sx,int sy,int fx,int fy)
{
if(mp[fx][fy] && mp[fx][fy]/10 == mp[sx][sy]/10)return 0;
if(abs(sx-fx)<=1 && abs(sy-fy)<=1)
{
return 1;
}
return 0;
}
void chidiao(int x,int y)
{
if(!mp[x][y])cout <<"NA;";
else
{
if(mp[x][y]/10)
{
bl.erase({x,y});
cout << "blue ";
}else
{
re.erase({x,y});
cout <<"red ";
}
cout << name[mp[x][y]%10]<<";";
mp[x][y]=0;
}
}
bool jiangjun(int x,int y)
{
int fang=mp[x][y]/10;
rep(i,1,10)
{
rep(j,1,9)
{
if(i==x && j==y)continue;
if(mp[i][j]/10!=fang)
{
int xx=mp[i][j]%10;
if(xx==1 && che(i,j,x,y))return 1;
if(xx==2 && ma(i,j,x,y))return 1;
if(xx==3 && xiang(i,j,x,y))return 1;
if(xx==4 && shi(i,j,x,y))return 1;
if(xx==5 && wang(i,j,x,y))return 1;
if(xx==6 && ya(i,j,x,y))return 1;
if(xx==7 && bing(i,j,x,y))return 1;
}
}
}
return 0;
}
void solve()
{
init();
int q;
cin >> q;
int nu=0;
while(q--)
{
int xs,ys,xt,yt;
cin >> xs >> ys >> xt >> yt;
xs++;
ys++;
xt++;
yt++;
int st=mp[xs][ys];
int fi=mp[xt][yt];
if(!st||fff||mp[xs][ys]/10!=nu)
{nu^=1;
cout << "Invalid command"<<endl;
continue;
}
int x=st%10;
if(x==1)
{
if(!che(xs,ys,xt,yt))
{nu^=1;
cout << "Invalid command"<<endl;
continue;
}else
{
if(nu%2==0)
{
cout <<"red car;";
}else {
cout << "blue car;";
}
chidiao(xt,yt);
}
}else if(x==2)
{
if(!ma(xs,ys,xt,yt))
{nu^=1;
cout << "Invalid command"<<endl;
continue;
}else
{
if(nu%2==0)
{
cout <<"red horse;";
}else {
cout << "blue horse;";
}
chidiao(xt,yt);
}
}else if(x==3)
{
if(!xiang(xs,ys,xt,yt))
{nu^=1;
cout << "Invalid command"<<endl;
continue;
}else
{
if(nu%2==0)
{
cout <<"red elephant;";
}else {
cout << "blue elephant;";
}
chidiao(xt,yt);
}
}else if( x==4)
{
if(!shi(xs,ys,xt,yt))
{nu^=1;
cout << "Invalid command"<<endl;
continue;
}else
{
if(nu%2==0)
{
cout <<"red guard;";
}else {
cout << "blue guard;";
}
chidiao(xt,yt);
}
}else if(x==5)
{
if(!wang(xs,ys,xt,yt))
{nu^=1;
cout << "Invalid command"<<endl;
continue;
}else
{
if(nu%2==0)
{
cout <<"red captain;";
}else {
cout << "blue captain;";
}
chidiao(xt,yt);
}
}else if(x==6)
{
if(!ya(xs,ys,xt,yt))
{nu^=1;
cout << "Invalid command"<<endl;
continue;
}else
{
if(nu%2==0)
{
cout <<"red duck;";
}else {
cout << "blue duck;";
}
chidiao(xt,yt);
}
}else if( x==7)
{
if(!bing(xs,ys,xt,yt))
{nu^=1;
cout << "Invalid command"<<endl;
continue;
}else
{
if(nu%2==0)
{
cout <<"red soldier;";
}else {
cout << "blue soldier;";
}
chidiao(xt,yt);
}
}
swap(mp[xs][ys], mp[xt][yt]);
int ff = 0;
rep(i, 1, 10)
rep(j, 1, 9)
{
if(mp[i][j]%10==5)
{
if(jiangjun(i,j))
{
ff=1;
break;
}
}
}
if(ff) cout<<"yes;";
else cout<<"no;";
if(name[mp[xt][yt]%10]=="captain" && mp[xt][yt]/10!=nu)
{
cout<<"yes";
fff = 1;
}
else cout<<"no";
// cout<<re.size()<<":::"<<bl.size()<<"\n";
cout<<endl;
nu^=1;
}
}
signed main()
{
IOS;
int _;
//cin >> _;
_ = 1;
while(_ -- )
{
// number++;
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3716kb
input:
18 0 0 7 0 9 0 8 0 0 1 1 3 0 2 2 0 0 3 1 2 0 4 0 3 9 4 8 4 3 2 2 3 7 0 4 2 7 0 5 3 9 2 7 4 2 0 4 3 9 1 8 3 4 3 6 6 7 4 9 2 8 4 9 4 6 6 9 4 9 8 8 8
output:
Invalid command blue car;NA;no;no Invalid command Invalid command red guard;NA;no;no Invalid command Invalid command Invalid command Invalid command Invalid command Invalid command Invalid command Invalid command Invalid command Invalid command Invalid command Invalid command blue car;NA;no;no
result:
wrong answer 2nd lines differ - expected: 'Invalid command', found: 'blue car;NA;no;no'