QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#234395 | #1811. How to Move the Beans | CharlieVinnie | WA | 3ms | 6392kb | C++23 | 2.3kb | 2023-11-01 16:53:10 | 2023-11-01 16:53:11 |
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;});
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]=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; For(i,1,m) fl[i][o]=u=Mex(u,f[k+1][i]);
u=o; Rev(i,m,1) fr[i][o]=u=Mex(u,f[k+1][i]);
}
debug(k); For(i,1,m) debuga(tl[i],0,3),debuga(tr[i],0,3),debuga(fl[i],0,3),debuga(fr[i],0,3);
For(i,1,m) f[k][i]=Mex(fl[L(i)][tl[i][3]],fr[R(i)][tr[i][3]],f[k+1][i]);
}
}
For(i,1,n) debuga(f[i],1,m);
int ans=0; For(i,1,n) For(j,1,m) if(mp[i][j]=='B') ans^=f[i][j];; debug(ans); 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
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 5752kb
input:
2 3 B.# #..
output:
Alice
result:
ok "Alice"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3972kb
input:
1 1 B
output:
Bob
result:
ok "Bob"
Test #3:
score: 0
Accepted
time: 0ms
memory: 3744kb
input:
1 3 B#.
output:
Alice
result:
ok "Alice"
Test #4:
score: 0
Accepted
time: 0ms
memory: 3996kb
input:
5 18 #.#..#.#..###..### ##...#.#..#.#..#.. #....#.#..###..#.. ##...#.#..#....#.. #.#..###..#....###
output:
Bob
result:
ok "Bob"
Test #5:
score: 0
Accepted
time: 3ms
memory: 6392kb
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: 0ms
memory: 4080kb
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: 3880kb
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: 3840kb
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: -100
Wrong Answer
time: 3ms
memory: 4828kb
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:
Alice
result:
wrong answer 1st words differ - expected: 'Bob', found: 'Alice'