QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#234435 | #1811. How to Move the Beans | CharlieVinnie | WA | 0ms | 3824kb | C++23 | 2.6kb | 2023-11-01 17:18:25 | 2023-11-01 17:18:25 |
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]=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(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) debug(i),debuga(tl[i],0,3),debuga(tr[i],0,3),debuga(fl[i],0,3),debuga(fr[i],0,3);
For(i,1,m) debug(fr[R(i)][tr[i][3]]),f[k][i]=Mex(fl[L(i)][tl[i][3]],fr[R(i)][tr[i][3]],f[k+1][i]);
}
}
For(i,1,n){
For(j,1,m) cout<<f[i][j]<<' ';; cout<<'\n';
}
// 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: 0
Wrong Answer
time: 0ms
memory: 3824kb
input:
2 3 B.# #..
output:
1 2 3 3 1 1
result:
wrong answer 1st words differ - expected: 'Alice', found: '1'