QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#235399#1811. How to Move the BeanslefyWA 5ms8004kbC++232.3kb2023-11-02 18:40:582023-11-02 18:40:58

Judging History

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

  • [2023-11-02 18:40:58]
  • 评测
  • 测评结果:WA
  • 用时:5ms
  • 内存:8004kb
  • [2023-11-02 18:40:58]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int N=1010;
char a[N][N];
int n,m;
int get(vector<int>a){
	int vis[4];vis[0]=vis[1]=vis[2]=vis[3]=0;
	for(int x:a)if(x>=0&&x<=3)vis[x]=1;
	for(int i=0;i<4;i++)if(!vis[i])return i;
	return -1;
}
int sg[N][N],l[N],r[N],s[N],e[N];
int L1[N][5],L2[N][5],R1[N][5],R2[N][5];
void sol2(int i){
	for(int k=0;k<=3;k++)L1[1][k]=R1[m][k]=L2[m][k]=R2[1][k]=k;
	for(int j=2;j<=m;j++)for(int k=0;k<=3;k++){
		L1[j][k]=get({L1[j-1][k],sg[i+1][j]});
		R2[j][k]=R2[j-1][get({k,sg[i+1][j-1]})];
	}
	for(int j=m-1;j;j--)for(int k=0;k<=3;k++){
		L2[j][k]=L2[j+1][get({k,sg[i+1][j+1]})];
		R1[j][k]=get({R1[j+1][k],sg[i+1][j]});
	}
	for(int j=1;j<=m;j++){
		int L=-1,R=-1;
		if(m!=1){
			if(i!=m)L=L1[j-1][get({sg[i+1][1],L2[j+1][sg[i+1][j+1]]})];
			else L=L1[j-1][sg[i+1][1]];
			if(i!=1)R=R1[j+1][get({sg[i+1][m],R2[j-1][sg[i+1][j-1]]})];
			else R=R1[j+1][sg[i+1][m]];
		}
		sg[i][j]=get({L,R,sg[i+1][j]});
	}
}
void sol1(int i){
	int st=s[i],ed=e[i];
	for(int j=1;j<=m;j++)if(a[i][j]=='#')l[i]=r[i]=-1;
	for(int j=st+1;j<=m;j++)if(a[i][j]!='#'){
		l[j]=get({l[j-1],sg[i+1][j]});
	}
	if(a[i][1]!='#'){
		l[1]=get({l[m],sg[i+1][1]});
	}
	for(int j=2;j<st;j++)if(a[i][j]!='#'){
		l[j]=get({l[j-1],sg[i+1][j]});
	}
	for(int j=ed-1;j;j--)if(a[i][j]!='#'){
		r[j]=get({r[j+1],sg[i+1][j]});
	}
	if(a[i][m]!='#'){
		r[m]=get({r[1],sg[i+1][m]});
	}
	for(int j=m-1;j>ed;j--)if(a[i][j]!='#'){
		r[j]=get({r[j+1],sg[i+1][j]});
	}
	for(int j=1;j<=m;j++)if(a[i][j]!='#'){
		int le=j-1?j-1:m,ri=j+1<=m?j+1:1;
		sg[i][j]=get({sg[i+1][j],l[le],r[ri]});
	}else sg[i][j]=4;
}
void solve(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++){
		scanf("%s",a[i]+1);
		int st=-1,ed=-1;
		for(int j=1;j<=m;j++){
			if(a[i][j]=='#'){
				if(st==-1)st=j;
				ed=j;
			}
		}
		s[i]=st,e[i]=ed;
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++)sg[i][j]=0;
		sg[i][0]=sg[i][m+1]=4;
	}
	for(int j=0;j<=m+1;j++)sg[n+1][j]=4;
	int ans=0;
	for(int i=n;i;i--){
		int st=s[i],ed=e[i];
		if(st!=-1)sol1(i);
		else sol2(i);
		for(int j=1;j<=m;j++)if(a[i][j]=='B')ans^=sg[i][j];
	}
	if(ans)printf("Alice\n");
	else printf("Bob\n");
}
int main(){
	// freopen("chequer.in","r",stdin);
	// freopen("chequer.out","w",stdout);
	// int t;
	// scanf("%d",&t);
	// while(t--)
	 solve();
	return 0;
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3856kb

input:

2 3
B.#
#..

output:

Alice

result:

ok "Alice"

Test #2:

score: 0
Accepted
time: 0ms
memory: 3836kb

input:

1 1
B

output:

Bob

result:

ok "Bob"

Test #3:

score: 0
Accepted
time: 0ms
memory: 3888kb

input:

1 3
B#.

output:

Alice

result:

ok "Alice"

Test #4:

score: 0
Accepted
time: 0ms
memory: 3920kb

input:

5 18
#.#..#.#..###..###
##...#.#..#.#..#..
#....#.#..###..#..
##...#.#..#....#..
#.#..###..#....###

output:

Bob

result:

ok "Bob"

Test #5:

score: 0
Accepted
time: 5ms
memory: 7236kb

input:

293 249
#B..B..BBB..B.B.B...#BBB..B#B.BBB.#B##B.BB.B.##B#B.BB..B.#B#BB.BB##B#BB#...B..BB..B.B##B.B#B.#.##..B.#..BBBB#.BB..#.BBB#B##BB....B.##B..#...B#..B.BB#B.#...B#.BB.#B#.B...BBB.B.B..B....##.B..B##.BB#B.B.BBB.B#B..#.B.B#.B##..B#.##BB.#BB#.BB.#.B..BB.BB.B
BB.B.#.B#BB.B.B..B.###.B...BB.##.B...B#BB....

output:

Alice

result:

ok "Alice"

Test #6:

score: 0
Accepted
time: 1ms
memory: 8004kb

input:

75 13
BBB.B.BB.B.#B
BB.##...B##BB
..#.B....#.B.
BBB..#...B#BB
#B#.##B..BB..
#B..BBBB.B..#
#B##.BBBBB.B#
BBB.B..#B#B..
.BBB####.##BB
.B##...#.#.#.
#.BB#..B.B.B.
BB#BB.BBB..BB
B.#...#.BBBBB
..#B.BBBB..B#
BB..B..#.....
..B..BBBB.B#.
.B.B##B.#B.##
BBBB#...#..B#
B.BB..BBB#B.B
.#B#B...BB.BB
#.B...BB...B.
...

output:

Alice

result:

ok "Alice"

Test #7:

score: 0
Accepted
time: 1ms
memory: 6016kb

input:

35 38
#.#..B.B.#.BB#.B.B.B..##..B#B###BBB##.
.#.#.B#.#BBB..B..BB.#..BB..##B......#B
B.B#..B..B...##B#B..#.##.#..B.#..B##BB
#.B.B..#..B#.#.B#B##B.BBB..#.B...B..#.
B#.#.BBB..B.BB.B..BBBBB##B..BB#.B#.BB.
B##.B#...B.B.BB.BBB..#BBB.#..#B#.B..#B
B....B#B.#.BBB.B#BB...##B#...B..BB.BB.
..###.#.B#....#.....#...

output:

Alice

result:

ok "Alice"

Test #8:

score: -100
Wrong Answer
time: 1ms
memory: 4080kb

input:

36 106
BB.B..B.BBBB.BB..BB..BB..BB...BB.B..B.B..BBBB.B.BB..B.B..BB..BBBB.B.B.BBBB..B.BBBBBBBBBBBBBBB.BB.B.BBB..BB
#BBB.BBB#..#.BB...###B.B#.B...B.#.BBBB.B..B..#B.#B#BB##.BB.#B..B#B...B....B#B#.#B.B.B.BB#..B#B#.#.#B###.B.
B.BBB.BBBBB.BBB....BB..B.BBBB.BBB.BBB.BBB.B.B.BBB.B...B.B.BBBBB.BBB....BB.BBB.B...

output:

Bob

result:

wrong answer 1st words differ - expected: 'Alice', found: 'Bob'