QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#234438 | #1811. How to Move the Beans | CharlieVinnie | WA | 2ms | 6372kb | C++23 | 2.3kb | 2023-11-01 17:18:53 | 2023-11-01 17:18:53 |
Judging History
answer
#include "bits/stdc++.h"
#ifdef DEBUG
#include "PrettyDebug.hpp"
#else
#define debug(...) [](auto...){}(__VA_ARGS__)
#define debuga(...) [](auto...){}(__VA_ARGS__)
#endif
#define For(i,a,b) for(int i=a;i<=b;i++)
#define Rev(i,a,b) for(int i=a;i>=b;i--)
#define Fin(file) freopen(file,"r",stdin)
#define Fout(file) freopen(file,"w",stdout)
#define assume(expr) ((!!(expr))||(exit((fprintf(stderr,"Assumption Failed: %s on Line %d\n",#expr,__LINE__),-1)),false))
#define range basic_string_view
using namespace std; typedef long long ll;
constexpr int N=1e3+5;
int n,m,f[N][N]; string mp[N];
inline int Mex(int x=3,int y=3,int z=3) { int o=0; while(o==x||o==y||o==z) o++;; return o; }
inline int L(int x) { return x==1?m:x-1; }
inline int R(int x) { return x==m?1:x+1; }
signed main(){
atexit([](){cerr<<"Time = "<<clock()<<" ms"<<endl;}); ios::sync_with_stdio(0); cin.tie(0);
cin>>n>>m; For(i,1,n) cin>>mp[i],mp[i]=' '+mp[i];
For(i,1,m) f[n+1][i]=3;
Rev(k,n,1){
if(m==1) { f[k][1]=Mex(f[k+1][1]); continue; }
int ok=0; For(i,1,m) if(mp[k][i]=='#') { ok=1; break; }
if(ok){
static int fl[N],fr[N];
For(_,0,1) For(i,1,m) fl[i]=mp[k][i]=='#'?3:Mex(fl[L(i)],f[k+1][i]);
For(_,0,1) Rev(i,m,1) fr[i]=mp[k][i]=='#'?3:Mex(fr[R(i)],f[k+1][i]);
For(i,1,m) f[k][i]=mp[k][i]=='#'?3:Mex(fl[L(i)],fr[R(i)],f[k+1][i]);
}
else{
static int tl[N][4],tr[N][4],fl[N][4],fr[N][4];
For(o,0,3) tl[m][o]=tr[1][o]=o;
Rev(i,m-1,1) For(o,0,3) tl[i][o]=tl[i+1][Mex(o,f[k+1][i+1])];
For(i,1+1,m) For(o,0,3) tr[i][o]=tr[i-1][Mex(o,f[k+1][i-1])];
For(o,0,3){
int u=o; fl[m][o]=o; For(i,1,m-1) fl[i][o]=u=Mex(u,f[k+1][i]);
u=o; fr[1][o]=o; Rev(i,m,1+1) fr[i][o]=u=Mex(u,f[k+1][i]);
}
For(i,1,m) f[k][i]=Mex(fl[L(i)][tl[i][3]],fr[R(i)][tr[i][3]],f[k+1][i]);
}
}
int ans=0; For(i,1,n) For(j,1,m) if(mp[i][j]=='B') ans^=f[i][j];; cout<<(ans?"Alice\n":"Bob\n");
return 0;
}
// START TYPING IF YOU DON'T KNOW WHAT TO DO
// STOP TYPING IF YOU DON'T KNOW WHAT YOU'RE DOING
// CONTINUE, NON-STOPPING, FOR CHARLIEVINNIE
// Started Coding On: November 01 Wed, 16 : 17 : 15
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3960kb
input:
2 3 B.# #..
output:
Alice
result:
ok "Alice"
Test #2:
score: 0
Accepted
time: 1ms
memory: 5724kb
input:
1 1 B
output:
Bob
result:
ok "Bob"
Test #3:
score: 0
Accepted
time: 0ms
memory: 3780kb
input:
1 3 B#.
output:
Alice
result:
ok "Alice"
Test #4:
score: 0
Accepted
time: 0ms
memory: 3740kb
input:
5 18 #.#..#.#..###..### ##...#.#..#.#..#.. #....#.#..###..#.. ##...#.#..#....#.. #.#..###..#....###
output:
Bob
result:
ok "Bob"
Test #5:
score: 0
Accepted
time: 0ms
memory: 6372kb
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: 6056kb
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: 0ms
memory: 4124kb
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: 3884kb
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: 2ms
memory: 6020kb
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: 5852kb
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: 0ms
memory: 4204kb
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'