QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#21348 | #2821. 鸭棋 | DaBenZhongXiaSongKuaiDi# | WA | 0ms | 3652kb | C++20 | 4.8kb | 2022-03-04 16:32:47 | 2022-05-08 02:55:06 |
Judging History
answer
#include<iostream>
#include<cstdio>
using namespace std;
inline int read()
{
int n=0,f=1,ch=getchar();
while(ch<'0'||ch>'9')
{
if(ch=='-')f=-1;
ch=getchar();
}
while(ch>='0'&&ch<='9')
{
n=n*10+ch-'0';
ch=getchar();
}
return n*f;
}
int a[11][11];
//1=王 2=士 3=象 4=马 5=车 6=兵 7=鸭
int jdz(int x)
{
if(x<0)return -x;
return x;
}
bool check(int x1,int y1,int x2,int y2)
{
if(a[x1][y1]*a[x2][y2]>0)
{
return false;
}
if(a[x1][y1]==1||a[x1][y1]==-1)
{
if(jdz(x2-x1)+jdz(y2-y1)!=1)
{
return false;
}
return true;
}
if(a[x1][y1]==2||a[x1][y1]==-2)
{
if(jdz(x2-x1)==1&&jdz(y2-y1)==1)return true;
return false;
}
if(a[x1][y1]==3||a[x1][y1]==-3)
{
if(jdz(x2-x1)!=2||jdz(y2-y1)!=2)return false;
int sx=(x2-x1)/2,sy=(y2-y1)/2;
if(a[x1+sx][y1+sy]!=0)return false;
return true;
}
if(a[x1][y1]==4||a[x1][y1]==-4)
{
if(jdz(x2-x1)==2&&jdz(y2-y1)==1)
{
int sx=(x2-x1)/2,sy=(y2-y1);
if(a[x1+sx][y1]!=0)return false;
return true;
}
if(jdz(x2-x1)==1&&jdz(y2-y1)==2)
{
int sx=x2-x1,sy=(y2-y1)/2;
if(a[x1][y1+sy]!=0)return false;
return true;
}
}
if(a[x1][y1]==5||a[x1][y1]==-5)
{
if(x2==x1&&y2==y1)return false;
if(x2==x1)
{
if(y2<=y1)
{
for(int j=y2+1;j<=y1-1;j++)if(a[x1][j]!=0)return false;
return true;
}
else
{
for(int j=y1+1;j<=y2-1;j++)if(a[x1][j]!=0)return false;
return true;
}
}
if(y2==y1)
{
if(x2<=x1)
{
for(int j=x2+1;j<=x1-1;j++)if(a[j][y1]!=0)return false;
return true;
}
else
{
for(int j=x1+1;j<=x2-1;j++)if(a[j][y1]!=0)return false;
return true;
}
}
return false;
}
if(a[x1][y1]==-6||a[x1][y1]==6)
{
if(jdz(x1-x2)<=1&&jdz(y2-y1)<=1)return true;
return false;
}
if(a[x1][y1]==-7||a[x1][y1]==7)
{
if(jdz(x1-x2)==3||jdz(y1-y2)==2)
{
int sx=(x2-x1)/3,sy=(y2-y1)/2;
if(a[x1+sx][y1]!=0||a[x1+2*sx][y1+sy]!=0)return false;
return true;
}
if(jdz(x1-x2)==2||jdz(y1-y2)==3)
{
int sx=(x2-x1)/2,sy=(y2-y1)/3;
if(a[x1][y1+sy]!=0||a[x1+sx][y1+2*sy]!=0)return false;
return true;
}
}
}
int main()
{
int q,n,m,x1,y1,x2,y2;
q=read();
a[1][1]=5;
a[1][2]=4;
a[1][3]=3;
a[1][4]=2;
a[1][5]=1;
a[1][6]=2;
a[1][7]=3;
a[1][8]=4;
a[1][9]=5;
a[4][1]=a[4][3]=a[4][5]=a[4][7]=a[4][9]=6;
a[3][1]=a[3][9]=7;
a[10][1]=-5;
a[10][2]=-4;
a[10][3]=-3;
a[10][4]=-2;
a[10][5]=-1;
a[10][6]=-2;
a[10][7]=-3;
a[10][8]=-4;
a[10][9]=-5;
a[7][1]=a[7][3]=a[7][5]=a[7][7]=a[7][9]=-6;
a[8][1]=a[8][9]=-7;
int hf=0,sth;
bool flag=true;
for(int i=1;i<=q;i++)
{
x1=read()+1;
y1=read()+1;
x2=read()+1;
y2=read()+1;
if(flag==false)
{
printf("Invalid command\n");
continue;
}
if(x1<1||x1>9||y1<1||y1>10||x2<1||x2>9||y1<1||y1>10)
{
printf("Invalid command\n");
continue;
}
if(a[x1][y1]==0)
{
printf("Invalid command\n");
continue;
}
if(hf==0&&a[x1][y1]<0)
{
printf("Invalid command\n");
continue;
}
if(hf==1&&a[x1][y1]>0)
{
printf("Invalid command\n");
continue;
}
if(check(x1,y1,x2,y2)==false)
{
printf("Invalid command\n");
continue;
}
if(hf==0)printf("red ");
else printf("blue ");
if(jdz(a[x1][y1])==1)printf("captain;");
else if(jdz(a[x1][y1])==2)printf("guard;");
else if(jdz(a[x1][y1])==3)printf("elephant;");
else if(jdz(a[x1][y1])==4)printf("horse;");
else if(jdz(a[x1][y1])==5)printf("car;");
else if(jdz(a[x1][y1])==6)printf("soldier;");
else printf("duck;");
if(a[x2][y2]==0)printf("NA;");
else
{
if(hf==0)printf("blue ");
else printf("red ");
if(jdz(a[x2][y2])==1)printf("captain;");
else if(jdz(a[x2][y2])==2)printf("guard;");
else if(jdz(a[x2][y2])==3)printf("elephant;");
else if(jdz(a[x2][y2])==4)printf("horse;");
else if(jdz(a[x2][y2])==5)printf("car;");
else if(jdz(a[x2][y2])==6)printf("soldier;");
else printf("duck;");
}
if(hf==0&&a[x2][y2]==-1)
{
flag=false;
printf("no;yes\n");
continue;
}
if(hf==1&&a[x2][y2]==1)
{
flag=false;
printf("no;yes\n");
continue;
}
if(hf==0)
{
sth=0;
for(int i=1;i<=10;i++)
{
for(int j=1;j<=9;j++)
{
if(a[i][j]==-1)
{
if(check(x1,y1,i,j)==true)
{
sth=1;
}
else sth=-1;
}
}
}
if(sth==1)printf("yes;no\n");
else printf("no;no\n");
hf^=1;
}
else
{
sth=0;
for(int i=1;i<=10;i++)
{
for(int j=1;j<=9;j++)
{
if(a[i][j]==1)
{
if(check(x1,y1,i,j)==true)
{
sth=1;
}
else sth=-1;
}
}
}
if(sth==1)printf("yes;no\n");
else printf("no;no\n");
hf^=1;
}
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3652kb
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 Invalid command 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 Invalid command
result:
wrong answer 7th lines differ - expected: 'blue captain;NA;no;no', found: 'Invalid command'