QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#21360 | #2821. 鸭棋 | DaBenZhongXiaSongKuaiDi# | WA | 2ms | 3520kb | C++20 | 5.0kb | 2022-03-04 16:52:42 | 2022-05-08 02:55:55 |
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;
}
return false;
}
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)
{
//printf("orz%d %d %d %d\n",x1,y1,x2,y2);
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;
//printf("???%d\n",a[x1][y1]);
if(flag==false)
{
printf("Invalid command\n");
continue;
}
if(x1<1||x1>10||y1<1||y1>9||x2<1||x2>10||y2<1||y2>9)
{
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;
}
a[x2][y2]=a[x1][y1];
a[x1][y1]=0;
sth=0;
for(int i=1;i<=10;i++)
{
for(int j=1;j<=9;j++)
{
if(a[i][j]==-1)
{
//printf("%d %d\n",i,j);
for(int k=1;k<=10;k++)
{
for(int l=1;l<=9;l++)
{
if(a[k][l]>0&&check(k,l,i,j))sth=1;
}
}
}
}
}
for(int i=1;i<=10;i++)
{
for(int j=1;j<=9;j++)
{
if(a[i][j]==1)
{
//printf("%d %d\n",i,j);
for(int k=1;k<=10;k++)
{
for(int l=1;l<=9;l++)
{
if(a[k][l]<0&&check(k,l,i,j))sth=1;
}
}
}
}
}
if(sth==1)printf("yes;no\n");
else printf("no;no\n");
hf^=1;
}
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 2ms
memory: 3520kb
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;yes;no Invalid command blue captain;NA;yes;no red soldier;NA;yes;no Invalid command Invalid command blue elephant;NA;yes;no red duck;NA;yes;no blue horse;NA;yes;no red duck;blue soldier;yes;no Invalid command blue captain;N...
result:
wrong answer 5th lines differ - expected: 'red guard;NA;no;no', found: 'red guard;NA;yes;no'