QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#123186#1811. How to Move the BeansEastKingWA 3ms14080kbC++173.0kb2023-07-11 20:42:042023-07-11 20:42:07

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-07-11 20:42:07]
  • 评测
  • 测评结果:WA
  • 用时:3ms
  • 内存:14080kb
  • [2023-07-11 20:42:04]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
char s[1005][2005];
int R[1005][2005],L[1005][2005];
int STL[1005][11][4];
int STR[1005][11][4];
int dp[1005][1005];
int mex(int x=4,int y=4,int z=4){
    for(int i=0;i<=4;i++){
        if(x!=i&&y!=i&&z!=i)return i;
    }
}
int main(){
    int H,W;
    scanf("%d%d",&H,&W);
    for(int i=0;i<H;i++){
        scanf("%s",s[i]);
    }
    for(int j=0;j<W;j++)s[H][j]='.';
    for(int i=0;i<H;i++){
    	for(int j=0;j<W;j++)s[i][j+W]='.';
        for(int j=0;j<2*W;j++){
            if(s[i][j]!='.')L[i][j]=max(1,L[i][j]+1);
            else L[i][j]=0;
            if(L[i][j%W]>W)L[i][j%W]=W;
        }
        for(int j=2*W-1;j>=0;j--){
            if(s[i][j%W]!='.')R[i][j%W]=max(1,R[i][(j+1)%W]+1);
            else R[i][j%W]=0;
            if(R[i][j%W]>W)R[i][j%W]=W;
        }
    }
    int ans=0;
    for(int i=H-1;i>=0;i--){
        memset(STL,0,sizeof(STL));
        memset(STR,0,sizeof(STR));
        for(int j=0;j<W;j++){
            for(int l=0;l<=3;l++){
                if(s[i+1][j]=='.'){
                    STL[j][0][l]=mex(l);

                    STR[j][0][l]=mex(l);
                }else{
                    STL[j][0][l]=mex(dp[i+1][j],l);

                    STR[j][0][l]=mex(dp[i+1][j],l);
                } 
            }
        }
        for(int k=1;k<=10;k++){
            for(int j=0;j<W;j++){
                for(int l=0;l<=3;l++){
                    STL[j][k][l]=STL[(j-(1<<(k-1))+W)%W][k-1][STL[j][k-1][l]];
                    STR[j][k][l]=STR[(j+(1<<(k-1))+W)%W][k-1][STR[j][k-1][l]];
                }
            }
        }
        //calc dp[i][j] len R[i][j]-1
        auto calcL=[&](int dis,int len){
            int ans=3;
            for(int j=10;j>=0;j--){
                if((len>>j)&1){
                    ans=STL[dis][j][ans];
                    dis=(dis-(1<<j)%W+W)%W;
                }
            }
            return ans;
        };
        auto calcR=[&](int dis,int len){
            int ans=3;
            for(int j=10;j>=0;j--){
                if((len>>j)&1){
                    ans=STR[dis][j][ans];
                    dis=(dis+(1<<j)+W)%W;
                }
            }
            return ans;
        };
        for(int j=0;j<W;j++){
            if(s[i][j]!='.'){
                int d1=4,d2=4,d3=4;
                if(s[i+1][j]!='.'){
                    d1=dp[i+1][j];
                }

                if(R[i][j]>1){
                    d2=calcL((i+R[i][j]-1+W)%W,R[i][j]-1);
                }
                if(L[i][j]>1){
                    d3=calcR((i-L[i][j]+1+W)%W,L[i][j]-1);
                }
                dp[i][j]=mex(d1,d2,d3);
            }
                //printf("dp[%d][%d]=%d\n",i,j,dp[i][j]);
        }
    }
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            if(s[i][j]=='B')ans^=dp[i][j];
        }
    }
    if(ans==0)printf("Bob");
    else printf("Alice");
    return 0;
}

詳細信息

Test #1:

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

input:

2 3
B.#
#..

output:

Alice

result:

ok "Alice"

Test #2:

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

input:

1 1
B

output:

Bob

result:

ok "Bob"

Test #3:

score: 0
Accepted
time: 2ms
memory: 7908kb

input:

1 3
B#.

output:

Alice

result:

ok "Alice"

Test #4:

score: 0
Accepted
time: 2ms
memory: 5900kb

input:

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

output:

Bob

result:

ok "Bob"

Test #5:

score: 0
Accepted
time: 3ms
memory: 14080kb

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: 7048kb

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: 2ms
memory: 8472kb

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: 0
Accepted
time: 1ms
memory: 6576kb

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:

Alice

result:

ok "Alice"

Test #9:

score: 0
Accepted
time: 3ms
memory: 13460kb

input:

245 239
.BBB.BB.B.BBB..B.BB.BBBBBB..B.BBB.B.BBBBBBBBB..B..BB.B.B.BB..B.BB...B.BB.B.BB..BBB..BB..BB.BBB.BBB.BBBBB.BBBB.BB.BBBB...BBB.B..BBBBBBB..BB..B.B.B..BBBBB...BB..BBB...BBB.B..BB.BB.B.BB.BBB..B.B.BBBB.BBBBB.BBB.BBBB.BB...B.B.B...BBB.BBB.BBB..B
B#.#BB..#BB.BBB#..BB..#.B#.##B.BBB###..B#B...BB..#.#...

output:

Bob

result:

ok "Bob"

Test #10:

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

input:

288 94
B....BB....BB.BBB.BBBB..B.B.B.....BBBB.B..BBBBBB.B..BBBBBBB....BBB.BBBBB.B.BBBB..B..B.B.BBB..B
BB#.#B#BBB.B#BB..BBB.B#BB#B#BB#BBBBBB####.B.B...BBB.BB.B.#.B.B.B.#.B.B.#.#..B..BB..B#..B.#....
BBBBBBB...B.BB.B..BB..BBBB.BBBBB.BBBB..BBBBBB.BB....B.BBBB.BB.BBB..B.BBBB.B.BBBBBB..BBB.BBB.B.
.B....B....

output:

Alice

result:

ok "Alice"

Test #11:

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

input:

119 1
B
.
#
.
B
.
#
#
#
.
B
B
#
B
#
#
#
B
#
B
.
.
B
B
B
B
.
B
B
B
B
#
#
.
B
B
B
.
B
.
#
B
B
.
#
B
.
#
.
B
B
B
B
B
B
#
#
B
B
B
#
.
.
#
.
B
B
B
B
.
B
B
.
B
B
B
#
#
B
B
.
#
#
B
B
.
B
.
#
.
B
B
B
B
#
B
.
B
B
.
B
B
.
#
#
B
.
.
.
#
.
.
B
.
.
B
.
.
#

output:

Bob

result:

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