QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#21375#2821. 鸭棋gogo#AC ✓15ms3696kbC++142.5kb2022-03-04 17:18:522022-05-08 02:57:09

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-05-08 02:57:09]
  • 评测
  • 测评结果:AC
  • 用时:15ms
  • 内存:3696kb
  • [2022-03-04 17:18:52]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
int END=0,a[15][15]={{5,4,3,2,1,2,3,4,5},{},{6,0,0,0,0,0,0,0,6},{7,0,7,0,7,0,7,0,7},{},{},{-7,0,-7,0,-7,0,-7,0,-7},{-6,0,0,0,0,0,0,0,-6},{},{-5,-4,-3,-2,-1,-2,-3,-4,-5}};
string name[10]={"ava","captain","guard","elephant","horse","car","duck","soldier"};
inline int D(int x,int y)
{
	return max(x,y)-min(x,y);
}
inline bool can(int sx,int sy,int tx,int ty)
{
	int dx=D(sx,tx),dy=D(sy,ty);
	if(!a[sx][sy]) return 0;
	if(a[tx][ty]*a[sx][sy]>0) return 0;
	if(END) return 0;
	if(dx+dy==0) return 0;
	int tp=max(a[sx][sy],-a[sx][sy]);
	if(tp==1) return (dx+dy==1);
	if(tp==2) return (dx==1&&dy==1);
	if(tp==3)
	{
		if(dx!=2||dy!=2) return 0;
		int px=(sx+tx)/2,py=(sy+ty)/2;
		return !a[px][py];
	}
	if(tp==4)
	{
		if(dx+dy!=3||max(dx,dy)!=2) return 0;
		int px=sx+(tx-sx)/2,py=sy+(ty-sy)/2;
		return !a[px][py];
	}
	if(tp==5)
	{
		for(int i=sx+1;i<=min(10,sx+10);i++)
		{
			if(tx==i&&ty==sy) return 1;
			if(a[i][sy]) break;
		}
		for(int i=sx-1;i>=max(0,sx-10);i--)
		{
			if(tx==i&&ty==sy) return 1;
			if(a[i][sy]) break;
		}
		for(int i=sy+1;i<=min(10,sy+10);i++)
		{
			if(tx==sx&&ty==i) return 1;
			if(a[sx][i]) break;
		}
		for(int i=sy-1;i>=max(0,sy-10);i--)
		{
			if(tx==sx&&ty==i) return 1;
			if(a[sx][i]) break;
		}
	}
	if(tp==6)
	{
		if(dx+dy!=5||max(dx,dy)!=3) return 0;
		int fx=(tx-sx)/D((tx-sx),0),fy=(ty-sy)/D((ty-sy),0);
		if(dx>dy) return !a[sx+fx][sy]&&!a[sx+fx+fx][sy+fy];
		return !a[sx][sy+fy]&&!a[sx+fx][sy+fy+fy];
	}
	if(tp==7) return max(dx,dy)<=1;
	return 0;
}
inline bool check()
{
	if(END) return 0;
	for(int i=0;i<10;i++) for(int j=0;j<9;j++)
		if(D(a[i][j],0)==1) for(int k=0;k<10;k++) for(int l=0;l<9;l++) if(can(k,l,i,j)) return 1;
	return 0;
}
inline bool End()
{
	if(END) return 1;
	int cnt=0;
	for(int i=0;i<10;i++)
		for(int j=0;j<9;j++) cnt+=D(a[i][j],0)==1;
	if(cnt!=2) return END=1;
	return 0;
}
signed main()
{
	int T,now=1;
	cin >> T;
	while(T--)
	{
		int sx,sy,tx,ty;
		cin >> sx >> sy >> tx >> ty;
		if(a[sx][sy]*now<=0||!can(sx,sy,tx,ty)) cout << "Invalid command\n";
		else
		{
			now*=-1;
			if(a[sx][sy]>0) cout << "red " << name[a[sx][sy]];
			else cout << "blue " << name[-a[sx][sy]];
			if(!a[tx][ty]) cout << ";NA";
			else if(a[tx][ty]>0) cout << ";red " << name[a[tx][ty]];
			else cout << ";blue " << name[-a[tx][ty]];
			a[tx][ty]=a[sx][sy],a[sx][sy]=0;End();
			if(check()) cout << ";yes";
			else cout << ";no";
			if(End()) cout << ";yes\n";
			else cout << ";no\n";
		}
	}
	return 0;
}

详细

Test #1:

score: 100
Accepted
time: 4ms
memory: 3640kb

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
blue captain;NA;no;no
red soldier;NA;no;no
Invalid command
Invalid command
blue elephant;NA;no;no
red duck;NA;no;no
blue horse;NA;no;no
red duck;blue soldier;no;no
Invalid command
blue captain;NA;yes;n...

result:

ok 18 lines

Test #2:

score: 0
Accepted
time: 7ms
memory: 3540kb

input:

1000
0 7 2 6
3 8 4 8
3 0 4 0
0 6 8 6
0 3 1 4
6 2 5 3
6 0 5 0
0 4 1 4
9 7 7 6
9 5 8 4
9 5 8 6
7 0 3 2
3 0 2 1
9 2 7 4
5 3 4 2
1 4 2 4
0 1 2 2
6 0 7 1
9 5 8 4
2 6 1 4
2 1 1 2
2 8 8 1
9 8 8 8
6 6 7 7
7 4 9 2
8 8 8 0
2 0 5 2
2 8 6 1
1 7 1 1
0 3 1 2
3 8 3 7
9 0 8 0
0 3 1 2
3 4 2 5
9 6 9 4
6 4 5 5
4 2 7 4...

output:

red horse;NA;no;no
Invalid command
Invalid command
Invalid command
Invalid command
blue soldier;NA;no;no
Invalid command
red captain;NA;no;no
blue horse;NA;no;no
Invalid command
Invalid command
Invalid command
red soldier;NA;no;no
blue elephant;NA;no;no
Invalid command
red captain;NA;no;no
Invalid c...

result:

ok 1000 lines

Test #3:

score: 0
Accepted
time: 15ms
memory: 3684kb

input:

1000
3 8 4 1
6 2 8 2
0 0 1 5
9 7 7 6
0 7 8 7
9 5 8 6
5 4 1 0
9 7 6 4
9 7 0 3
2 0 3 0
9 3 8 0
2 8 9 2
7 5 7 8
9 5 8 6
9 6 8 2
6 2 6 3
0 7 1 7
9 1 7 2
1 7 0 5
7 0 8 5
9 5 0 4
3 4 4 5
0 6 8 8
6 2 5 1
9 5 8 4
0 1 2 1
0 3 2 4
2 7 8 5
9 8 8 8
0 0 1 0
3 2 7 3
3 0 0 1
0 5 9 4
9 2 7 4
0 1 2 2
9 7 1 0
6 6 6 5...

output:

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
Invalid command
Invalid command
Invalid command
Invalid command
Invalid command
Invalid comm...

result:

ok 1000 lines

Test #4:

score: 0
Accepted
time: 11ms
memory: 3696kb

input:

1000
6 4 5 5
9 1 4 5
9 7 5 8
9 4 8 4
0 6 5 1
0 3 5 5
0 3 5 5
9 7 6 2
2 8 9 6
9 5 5 8
0 4 1 4
0 0 5 6
0 7 3 5
2 8 7 8
0 5 6 8
7 8 9 8
9 2 9 3
0 3 1 2
3 2 5 5
0 5 1 6
3 6 5 6
3 2 1 1
0 5 6 7
9 5 3 4
3 0 2 4
3 4 6 3
9 7 8 7
0 6 9 1
6 8 8 4
6 8 6 3
6 0 5 7
2 0 8 7
9 8 4 0
0 7 3 8
0 3 5 2
2 0 1 7
3 2 0 3...

output:

Invalid command
Invalid command
Invalid command
Invalid command
Invalid command
Invalid command
Invalid command
Invalid command
Invalid command
Invalid command
red captain;NA;no;no
Invalid command
Invalid command
Invalid command
Invalid command
Invalid command
Invalid command
Invalid command
Invalid...

result:

ok 1000 lines