QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#23921 | #2213. Knight | AFewSuns | AC ✓ | 92ms | 76912kb | C++14 | 2.3kb | 2022-03-21 09:43:37 | 2022-04-30 04:25:59 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
namespace my_std{
#define ll long long
#define bl bool
ll my_pow(ll a,ll b,ll mod){
ll res=1;
if(!b) return 1;
while(b){
if(b&1) res=(res*a)%mod;
a=(a*a)%mod;
b>>=1;
}
return res;
}
ll qpow(ll a,ll b){
ll res=1;
if(!b) return 1;
while(b){
if(b&1) res*=a;
a*=a;
b>>=1;
}
return res;
}
#define db double
#define pf printf
#define pc putchar
#define fr(i,x,y) for(register ll i=(x);i<=(y);i++)
#define pfr(i,x,y) for(register ll i=(x);i>=(y);i--)
#define go(u) for(ll i=head[u];i;i=e[i].nxt)
#define enter pc('\n')
#define space pc(' ')
#define fir first
#define sec second
#define MP make_pair
#define il inline
#define inf 8e18
#define random(x) rand()*rand()%(x)
#define inv(a,mod) my_pow((a),(mod-2),(mod))
il ll read(){
ll sum=0,f=1;
char ch=0;
while(!isdigit(ch)){
if(ch=='-') f=-1;
ch=getchar();
}
while(isdigit(ch)){
sum=sum*10+(ch^48);
ch=getchar();
}
return sum*f;
}
il void write(ll x){
if(x<0){
x=-x;
pc('-');
}
if(x>9) write(x/10);
pc(x%10+'0');
}
il void writeln(ll x){
write(x);
enter;
}
il void writesp(ll x){
write(x);
space;
}
}
using namespace my_std;
ll n,m,r,c,col[1010][1010],v[1010][1010],cnt[1000010],tot=0;
char s[1010][1010];
bl ck(ll x,ll y){
if(x>=1&&x<=n&&y>=1&&y<=m) if(s[x][y]!='@'&&!col[x][y]) return 1;
return 0;
}
void dfs(ll x,ll y,ll cl,ll w){
cnt[cl]++;
col[x][y]=cl;
v[x][y]=w;
if(ck(x+r,y+c)) dfs(x+r,y+c,cl,w^1);
if(ck(x+r,y-c)) dfs(x+r,y-c,cl,w^1);
if(ck(x-r,y+c)) dfs(x-r,y+c,cl,w^1);
if(ck(x-r,y-c)) dfs(x-r,y-c,cl,w^1);
if(ck(x+c,y+r)) dfs(x+c,y+r,cl,w^1);
if(ck(x+c,y-r)) dfs(x+c,y-r,cl,w^1);
if(ck(x-c,y+r)) dfs(x-c,y+r,cl,w^1);
if(ck(x-c,y-r)) dfs(x-c,y-r,cl,w^1);
}
int main(){
n=read();
m=read();
r=read();
c=read();
fr(i,1,n) scanf("%s",s[i]+1);
fr(i,1,n){
fr(j,1,m){
if(!col[i][j]&&s[i][j]!='@'){
tot++;
dfs(i,j,tot,0);
}
}
}
ll cola,va,colb,vb;
fr(i,1,n){
fr(j,1,m){
if(s[i][j]=='A'){
cola=col[i][j];
va=v[i][j];
}
if(s[i][j]=='B'){
colb=col[i][j];
vb=v[i][j];
}
}
}
if(cnt[cola]==1) pf("Bob");
else if(cola==colb&&va!=vb) pf("Bob");
else pf("Alice");
}
Details
Test #1:
score: 100
Accepted
time: 10ms
memory: 22844kb
Test #2:
score: 0
Accepted
time: 4ms
memory: 10064kb
Test #3:
score: 0
Accepted
time: 31ms
memory: 22468kb
Test #4:
score: 0
Accepted
time: 24ms
memory: 26440kb
Test #5:
score: 0
Accepted
time: 4ms
memory: 7820kb
Test #6:
score: 0
Accepted
time: 6ms
memory: 19088kb
Test #7:
score: 0
Accepted
time: 6ms
memory: 7980kb
Test #8:
score: 0
Accepted
time: 9ms
memory: 16360kb
Test #9:
score: 0
Accepted
time: 14ms
memory: 26388kb
Test #10:
score: 0
Accepted
time: 8ms
memory: 18144kb
Test #11:
score: 0
Accepted
time: 4ms
memory: 22640kb
Test #12:
score: 0
Accepted
time: 20ms
memory: 23248kb
Test #13:
score: 0
Accepted
time: 2ms
memory: 19220kb
Test #14:
score: 0
Accepted
time: 18ms
memory: 23824kb
Test #15:
score: 0
Accepted
time: 3ms
memory: 23068kb
Test #16:
score: 0
Accepted
time: 9ms
memory: 25200kb
Test #17:
score: 0
Accepted
time: 2ms
memory: 9960kb
Test #18:
score: 0
Accepted
time: 6ms
memory: 14664kb
Test #19:
score: 0
Accepted
time: 0ms
memory: 10220kb
Test #20:
score: 0
Accepted
time: 7ms
memory: 18592kb
Test #21:
score: 0
Accepted
time: 4ms
memory: 7900kb
Test #22:
score: 0
Accepted
time: 9ms
memory: 16552kb
Test #23:
score: 0
Accepted
time: 0ms
memory: 14044kb
Test #24:
score: 0
Accepted
time: 6ms
memory: 21656kb
Test #25:
score: 0
Accepted
time: 3ms
memory: 21444kb
Test #26:
score: 0
Accepted
time: 5ms
memory: 9992kb
Test #27:
score: 0
Accepted
time: 2ms
memory: 9988kb
Test #28:
score: 0
Accepted
time: 33ms
memory: 35644kb
Test #29:
score: 0
Accepted
time: 5ms
memory: 18264kb
Test #30:
score: 0
Accepted
time: 11ms
memory: 25160kb
Test #31:
score: 0
Accepted
time: 11ms
memory: 16656kb
Test #32:
score: 0
Accepted
time: 4ms
memory: 8024kb
Test #33:
score: 0
Accepted
time: 19ms
memory: 26032kb
Test #34:
score: 0
Accepted
time: 6ms
memory: 17060kb
Test #35:
score: 0
Accepted
time: 20ms
memory: 22068kb
Test #36:
score: 0
Accepted
time: 40ms
memory: 24296kb
Test #37:
score: 0
Accepted
time: 6ms
memory: 14520kb
Test #38:
score: 0
Accepted
time: 9ms
memory: 10984kb
Test #39:
score: 0
Accepted
time: 3ms
memory: 14148kb
Test #40:
score: 0
Accepted
time: 2ms
memory: 18288kb
Test #41:
score: 0
Accepted
time: 8ms
memory: 19428kb
Test #42:
score: 0
Accepted
time: 6ms
memory: 20632kb
Test #43:
score: 0
Accepted
time: 4ms
memory: 25092kb
Test #44:
score: 0
Accepted
time: 4ms
memory: 12308kb
Test #45:
score: 0
Accepted
time: 9ms
memory: 18364kb
Test #46:
score: 0
Accepted
time: 0ms
memory: 14172kb
Test #47:
score: 0
Accepted
time: 3ms
memory: 14568kb
Test #48:
score: 0
Accepted
time: 38ms
memory: 24592kb
Test #49:
score: 0
Accepted
time: 7ms
memory: 22632kb
Test #50:
score: 0
Accepted
time: 6ms
memory: 16364kb
Test #51:
score: 0
Accepted
time: 60ms
memory: 36204kb
Test #52:
score: 0
Accepted
time: 65ms
memory: 32340kb
Test #53:
score: 0
Accepted
time: 22ms
memory: 22268kb
Test #54:
score: 0
Accepted
time: 82ms
memory: 46740kb
Test #55:
score: 0
Accepted
time: 55ms
memory: 22976kb
Test #56:
score: 0
Accepted
time: 92ms
memory: 55736kb
Test #57:
score: 0
Accepted
time: 58ms
memory: 22828kb
Test #58:
score: 0
Accepted
time: 22ms
memory: 24296kb
Test #59:
score: 0
Accepted
time: 21ms
memory: 24308kb
Test #60:
score: 0
Accepted
time: 88ms
memory: 59104kb
Test #61:
score: 0
Accepted
time: 42ms
memory: 24384kb
Test #62:
score: 0
Accepted
time: 32ms
memory: 22244kb
Test #63:
score: 0
Accepted
time: 81ms
memory: 38344kb
Test #64:
score: 0
Accepted
time: 24ms
memory: 22324kb
Test #65:
score: 0
Accepted
time: 48ms
memory: 24732kb
Test #66:
score: 0
Accepted
time: 21ms
memory: 24364kb
Test #67:
score: 0
Accepted
time: 49ms
memory: 24024kb
Test #68:
score: 0
Accepted
time: 15ms
memory: 24372kb
Test #69:
score: 0
Accepted
time: 84ms
memory: 66668kb
Test #70:
score: 0
Accepted
time: 38ms
memory: 26632kb
Test #71:
score: 0
Accepted
time: 28ms
memory: 24312kb
Test #72:
score: 0
Accepted
time: 19ms
memory: 22316kb
Test #73:
score: 0
Accepted
time: 15ms
memory: 26268kb
Test #74:
score: 0
Accepted
time: 61ms
memory: 57288kb
Test #75:
score: 0
Accepted
time: 43ms
memory: 24528kb
Test #76:
score: 0
Accepted
time: 54ms
memory: 22580kb
Test #77:
score: 0
Accepted
time: 61ms
memory: 44736kb
Test #78:
score: 0
Accepted
time: 22ms
memory: 24352kb
Test #79:
score: 0
Accepted
time: 24ms
memory: 24224kb
Test #80:
score: 0
Accepted
time: 50ms
memory: 24292kb
Test #81:
score: 0
Accepted
time: 36ms
memory: 24440kb
Test #82:
score: 0
Accepted
time: 42ms
memory: 21656kb
Test #83:
score: 0
Accepted
time: 39ms
memory: 22384kb
Test #84:
score: 0
Accepted
time: 28ms
memory: 24312kb
Test #85:
score: 0
Accepted
time: 8ms
memory: 24372kb
Test #86:
score: 0
Accepted
time: 23ms
memory: 22120kb
Test #87:
score: 0
Accepted
time: 19ms
memory: 24264kb
Test #88:
score: 0
Accepted
time: 19ms
memory: 24348kb
Test #89:
score: 0
Accepted
time: 80ms
memory: 56536kb
Test #90:
score: 0
Accepted
time: 45ms
memory: 21680kb
Test #91:
score: 0
Accepted
time: 12ms
memory: 24336kb
Test #92:
score: 0
Accepted
time: 58ms
memory: 32400kb
Test #93:
score: 0
Accepted
time: 21ms
memory: 24304kb
Test #94:
score: 0
Accepted
time: 84ms
memory: 48396kb
Test #95:
score: 0
Accepted
time: 50ms
memory: 22064kb
Test #96:
score: 0
Accepted
time: 41ms
memory: 24536kb
Test #97:
score: 0
Accepted
time: 61ms
memory: 58864kb
Test #98:
score: 0
Accepted
time: 44ms
memory: 36980kb
Test #99:
score: 0
Accepted
time: 43ms
memory: 24960kb
Test #100:
score: 0
Accepted
time: 49ms
memory: 25448kb
Test #101:
score: 0
Accepted
time: 52ms
memory: 28272kb
Test #102:
score: 0
Accepted
time: 46ms
memory: 24624kb
Test #103:
score: 0
Accepted
time: 68ms
memory: 50712kb
Test #104:
score: 0
Accepted
time: 36ms
memory: 24756kb
Test #105:
score: 0
Accepted
time: 57ms
memory: 23600kb
Test #106:
score: 0
Accepted
time: 25ms
memory: 24160kb
Test #107:
score: 0
Accepted
time: 79ms
memory: 43560kb
Test #108:
score: 0
Accepted
time: 89ms
memory: 56696kb
Test #109:
score: 0
Accepted
time: 68ms
memory: 33180kb
Test #110:
score: 0
Accepted
time: 87ms
memory: 39780kb
Test #111:
score: 0
Accepted
time: 63ms
memory: 28512kb
Test #112:
score: 0
Accepted
time: 55ms
memory: 25140kb
Test #113:
score: 0
Accepted
time: 21ms
memory: 24356kb
Test #114:
score: 0
Accepted
time: 17ms
memory: 22312kb
Test #115:
score: 0
Accepted
time: 24ms
memory: 21808kb
Test #116:
score: 0
Accepted
time: 64ms
memory: 22076kb
Test #117:
score: 0
Accepted
time: 63ms
memory: 28816kb
Test #118:
score: 0
Accepted
time: 19ms
memory: 24348kb
Test #119:
score: 0
Accepted
time: 12ms
memory: 24264kb
Test #120:
score: 0
Accepted
time: 66ms
memory: 47748kb
Test #121:
score: 0
Accepted
time: 25ms
memory: 26336kb
Test #122:
score: 0
Accepted
time: 25ms
memory: 30808kb
Test #123:
score: 0
Accepted
time: 16ms
memory: 22344kb
Test #124:
score: 0
Accepted
time: 18ms
memory: 24268kb
Test #125:
score: 0
Accepted
time: 44ms
memory: 22804kb
Test #126:
score: 0
Accepted
time: 14ms
memory: 22180kb
Test #127:
score: 0
Accepted
time: 16ms
memory: 24316kb
Test #128:
score: 0
Accepted
time: 27ms
memory: 24368kb
Test #129:
score: 0
Accepted
time: 14ms
memory: 24352kb
Test #130:
score: 0
Accepted
time: 69ms
memory: 23660kb
Test #131:
score: 0
Accepted
time: 17ms
memory: 24360kb
Test #132:
score: 0
Accepted
time: 53ms
memory: 42316kb
Test #133:
score: 0
Accepted
time: 10ms
memory: 24380kb
Test #134:
score: 0
Accepted
time: 38ms
memory: 24156kb
Test #135:
score: 0
Accepted
time: 78ms
memory: 61228kb
Test #136:
score: 0
Accepted
time: 9ms
memory: 26400kb
Test #137:
score: 0
Accepted
time: 13ms
memory: 24372kb
Test #138:
score: 0
Accepted
time: 83ms
memory: 63124kb
Test #139:
score: 0
Accepted
time: 15ms
memory: 24340kb
Test #140:
score: 0
Accepted
time: 26ms
memory: 24356kb
Test #141:
score: 0
Accepted
time: 62ms
memory: 29876kb
Test #142:
score: 0
Accepted
time: 27ms
memory: 24296kb
Test #143:
score: 0
Accepted
time: 79ms
memory: 65180kb
Test #144:
score: 0
Accepted
time: 54ms
memory: 26668kb
Test #145:
score: 0
Accepted
time: 52ms
memory: 33120kb
Test #146:
score: 0
Accepted
time: 42ms
memory: 22576kb
Test #147:
score: 0
Accepted
time: 82ms
memory: 37572kb
Test #148:
score: 0
Accepted
time: 80ms
memory: 40020kb
Test #149:
score: 0
Accepted
time: 41ms
memory: 26476kb
Test #150:
score: 0
Accepted
time: 65ms
memory: 45972kb
Test #151:
score: 0
Accepted
time: 70ms
memory: 76912kb
Test #152:
score: 0
Accepted
time: 14ms
memory: 24260kb
Test #153:
score: 0
Accepted
time: 15ms
memory: 26416kb
Test #154:
score: 0
Accepted
time: 34ms
memory: 22320kb
Test #155:
score: 0
Accepted
time: 68ms
memory: 51656kb
Test #156:
score: 0
Accepted
time: 24ms
memory: 24308kb
Test #157:
score: 0
Accepted
time: 10ms
memory: 26404kb
Test #158:
score: 0
Accepted
time: 35ms
memory: 24368kb
Test #159:
score: 0
Accepted
time: 8ms
memory: 24356kb
Test #160:
score: 0
Accepted
time: 13ms
memory: 24360kb
Test #161:
score: 0
Accepted
time: 40ms
memory: 28208kb
Test #162:
score: 0
Accepted
time: 14ms
memory: 24488kb
Test #163:
score: 0
Accepted
time: 16ms
memory: 24352kb
Test #164:
score: 0
Accepted
time: 58ms
memory: 28536kb
Test #165:
score: 0
Accepted
time: 78ms
memory: 41244kb
Test #166:
score: 0
Accepted
time: 67ms
memory: 49812kb