QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#18409#2213. Knightfirahiko_owo#AC ✓62ms16728kbC++201.4kb2022-01-19 09:01:292022-05-04 18:20:13

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-05-04 18:20:13]
  • 评测
  • 测评结果:AC
  • 用时:62ms
  • 内存:16728kb
  • [2022-01-19 09:01:29]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head

const int N=1010;
int n,m,r,c,t;
int vis[N][N];
char s[N][N];
PII q[N*N],p1,p2;
int main() {
	scanf("%d%d%d%d",&n,&m,&r,&c);
	if (r==0&&c==0) {
		puts("Bob");
		return 0;
	}
	rep(i,0,n) scanf("%s",s[i]);
	rep(i,0,n) rep(j,0,m) {
		if (s[i][j]=='A') p1=mp(i,j);
		if (s[i][j]=='B') p2=mp(i,j);
	}
	int dx[]={r,r,c,c,-r,-r,-c,-c};
	int dy[]={c,-c,r,-r,c,-c,r,-r};
	bool go=0;
	rep(i,0,8) {
		int nx=p1.fi+dx[i],ny=p1.se+dy[i];
		if (nx>=0&&nx<n&&ny>=0&&ny<m&&s[nx][ny]=='.') go=1;
	}
	if (!go) {
		puts("Bob");
		return 0;
	}
	memset(vis,-1,sizeof(vis));
	q[t++]=p1;
	vis[p1.fi][p1.se]=0;
	rep(i,0,t) {
		int x=q[i].fi,y=q[i].se;
		rep(j,0,8) {
			int nx=x+dx[j],ny=y+dy[j];
			if (nx>=0&&nx<n&&ny>=0&&ny<m&&s[nx][ny]!='@'&&vis[nx][ny]==-1) {
				vis[nx][ny]=vis[x][y]^1;
				q[t++]=mp(nx,ny);
			}
		}
	}
	puts(vis[p2.fi][p2.se]==1?"Bob":"Alice");
}

Details

Test #1:

score: 100
Accepted
time: 1ms
memory: 5720kb

Test #2:

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

Test #3:

score: 0
Accepted
time: 10ms
memory: 12368kb

Test #4:

score: 0
Accepted
time: 13ms
memory: 12584kb

Test #5:

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

Test #6:

score: 0
Accepted
time: 6ms
memory: 5768kb

Test #7:

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

Test #8:

score: 0
Accepted
time: 4ms
memory: 5676kb

Test #9:

score: 0
Accepted
time: 5ms
memory: 5632kb

Test #10:

score: 0
Accepted
time: 10ms
memory: 9340kb

Test #11:

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

Test #12:

score: 0
Accepted
time: 9ms
memory: 9988kb

Test #13:

score: 0
Accepted
time: 9ms
memory: 12560kb

Test #14:

score: 0
Accepted
time: 6ms
memory: 9032kb

Test #15:

score: 0
Accepted
time: 6ms
memory: 9692kb

Test #16:

score: 0
Accepted
time: 7ms
memory: 7816kb

Test #17:

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

Test #18:

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

Test #19:

score: 0
Accepted
time: 5ms
memory: 9300kb

Test #20:

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

Test #21:

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

Test #22:

score: 0
Accepted
time: 4ms
memory: 7688kb

Test #23:

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

Test #24:

score: 0
Accepted
time: 8ms
memory: 7732kb

Test #25:

score: 0
Accepted
time: 6ms
memory: 9780kb

Test #26:

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

Test #27:

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

Test #28:

score: 0
Accepted
time: 21ms
memory: 12484kb

Test #29:

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

Test #30:

score: 0
Accepted
time: 8ms
memory: 9176kb

Test #31:

score: 0
Accepted
time: 4ms
memory: 9364kb

Test #32:

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

Test #33:

score: 0
Accepted
time: 15ms
memory: 12592kb

Test #34:

score: 0
Accepted
time: 5ms
memory: 5760kb

Test #35:

score: 0
Accepted
time: 13ms
memory: 12516kb

Test #36:

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

Test #37:

score: 0
Accepted
time: 6ms
memory: 8848kb

Test #38:

score: 0
Accepted
time: 6ms
memory: 11148kb

Test #39:

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

Test #40:

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

Test #41:

score: 0
Accepted
time: 4ms
memory: 7824kb

Test #42:

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

Test #43:

score: 0
Accepted
time: 8ms
memory: 8612kb

Test #44:

score: 0
Accepted
time: 5ms
memory: 7720kb

Test #45:

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

Test #46:

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

Test #47:

score: 0
Accepted
time: 4ms
memory: 7884kb

Test #48:

score: 0
Accepted
time: 9ms
memory: 12560kb

Test #49:

score: 0
Accepted
time: 11ms
memory: 9976kb

Test #50:

score: 0
Accepted
time: 6ms
memory: 9880kb

Test #51:

score: 0
Accepted
time: 52ms
memory: 16660kb

Test #52:

score: 0
Accepted
time: 26ms
memory: 12488kb

Test #53:

score: 0
Accepted
time: 5ms
memory: 10568kb

Test #54:

score: 0
Accepted
time: 28ms
memory: 14696kb

Test #55:

score: 0
Accepted
time: 13ms
memory: 9668kb

Test #56:

score: 0
Accepted
time: 42ms
memory: 16660kb

Test #57:

score: 0
Accepted
time: 48ms
memory: 12516kb

Test #58:

score: 0
Accepted
time: 9ms
memory: 5792kb

Test #59:

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

Test #60:

score: 0
Accepted
time: 49ms
memory: 16532kb

Test #61:

score: 0
Accepted
time: 11ms
memory: 9212kb

Test #62:

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

Test #63:

score: 0
Accepted
time: 60ms
memory: 16576kb

Test #64:

score: 0
Accepted
time: 10ms
memory: 9268kb

Test #65:

score: 0
Accepted
time: 6ms
memory: 9936kb

Test #66:

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

Test #67:

score: 0
Accepted
time: 20ms
memory: 12560kb

Test #68:

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

Test #69:

score: 0
Accepted
time: 58ms
memory: 16580kb

Test #70:

score: 0
Accepted
time: 23ms
memory: 10072kb

Test #71:

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

Test #72:

score: 0
Accepted
time: 5ms
memory: 9424kb

Test #73:

score: 0
Accepted
time: 7ms
memory: 7724kb

Test #74:

score: 0
Accepted
time: 51ms
memory: 16568kb

Test #75:

score: 0
Accepted
time: 4ms
memory: 10100kb

Test #76:

score: 0
Accepted
time: 15ms
memory: 10232kb

Test #77:

score: 0
Accepted
time: 53ms
memory: 16688kb

Test #78:

score: 0
Accepted
time: 9ms
memory: 9088kb

Test #79:

score: 0
Accepted
time: 7ms
memory: 5720kb

Test #80:

score: 0
Accepted
time: 47ms
memory: 14524kb

Test #81:

score: 0
Accepted
time: 6ms
memory: 10324kb

Test #82:

score: 0
Accepted
time: 8ms
memory: 9156kb

Test #83:

score: 0
Accepted
time: 9ms
memory: 5636kb

Test #84:

score: 0
Accepted
time: 10ms
memory: 9520kb

Test #85:

score: 0
Accepted
time: 8ms
memory: 10320kb

Test #86:

score: 0
Accepted
time: 6ms
memory: 10512kb

Test #87:

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

Test #88:

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

Test #89:

score: 0
Accepted
time: 46ms
memory: 16660kb

Test #90:

score: 0
Accepted
time: 10ms
memory: 8828kb

Test #91:

score: 0
Accepted
time: 7ms
memory: 10204kb

Test #92:

score: 0
Accepted
time: 22ms
memory: 12176kb

Test #93:

score: 0
Accepted
time: 6ms
memory: 5772kb

Test #94:

score: 0
Accepted
time: 53ms
memory: 16660kb

Test #95:

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

Test #96:

score: 0
Accepted
time: 12ms
memory: 10204kb

Test #97:

score: 0
Accepted
time: 62ms
memory: 16580kb

Test #98:

score: 0
Accepted
time: 40ms
memory: 16728kb

Test #99:

score: 0
Accepted
time: 6ms
memory: 12564kb

Test #100:

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

Test #101:

score: 0
Accepted
time: 9ms
memory: 10292kb

Test #102:

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

Test #103:

score: 0
Accepted
time: 50ms
memory: 16576kb

Test #104:

score: 0
Accepted
time: 4ms
memory: 9664kb

Test #105:

score: 0
Accepted
time: 9ms
memory: 10164kb

Test #106:

score: 0
Accepted
time: 5ms
memory: 9432kb

Test #107:

score: 0
Accepted
time: 33ms
memory: 16584kb

Test #108:

score: 0
Accepted
time: 45ms
memory: 16672kb

Test #109:

score: 0
Accepted
time: 47ms
memory: 14524kb

Test #110:

score: 0
Accepted
time: 33ms
memory: 14632kb

Test #111:

score: 0
Accepted
time: 39ms
memory: 12572kb

Test #112:

score: 0
Accepted
time: 12ms
memory: 9744kb

Test #113:

score: 0
Accepted
time: 4ms
memory: 5684kb

Test #114:

score: 0
Accepted
time: 6ms
memory: 5672kb

Test #115:

score: 0
Accepted
time: 5ms
memory: 9604kb

Test #116:

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

Test #117:

score: 0
Accepted
time: 5ms
memory: 9776kb

Test #118:

score: 0
Accepted
time: 11ms
memory: 9696kb

Test #119:

score: 0
Accepted
time: 13ms
memory: 5764kb

Test #120:

score: 0
Accepted
time: 50ms
memory: 14612kb

Test #121:

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

Test #122:

score: 0
Accepted
time: 11ms
memory: 7752kb

Test #123:

score: 0
Accepted
time: 6ms
memory: 5784kb

Test #124:

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

Test #125:

score: 0
Accepted
time: 35ms
memory: 14692kb

Test #126:

score: 0
Accepted
time: 4ms
memory: 9720kb

Test #127:

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

Test #128:

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

Test #129:

score: 0
Accepted
time: 9ms
memory: 9444kb

Test #130:

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

Test #131:

score: 0
Accepted
time: 14ms
memory: 9268kb

Test #132:

score: 0
Accepted
time: 48ms
memory: 14524kb

Test #133:

score: 0
Accepted
time: 12ms
memory: 5836kb

Test #134:

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

Test #135:

score: 0
Accepted
time: 52ms
memory: 16660kb

Test #136:

score: 0
Accepted
time: 4ms
memory: 7824kb

Test #137:

score: 0
Accepted
time: 8ms
memory: 10180kb

Test #138:

score: 0
Accepted
time: 52ms
memory: 16584kb

Test #139:

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

Test #140:

score: 0
Accepted
time: 4ms
memory: 9192kb

Test #141:

score: 0
Accepted
time: 13ms
memory: 12480kb

Test #142:

score: 0
Accepted
time: 12ms
memory: 5684kb

Test #143:

score: 0
Accepted
time: 42ms
memory: 16576kb

Test #144:

score: 0
Accepted
time: 14ms
memory: 10096kb

Test #145:

score: 0
Accepted
time: 35ms
memory: 16692kb

Test #146:

score: 0
Accepted
time: 16ms
memory: 10072kb

Test #147:

score: 0
Accepted
time: 12ms
memory: 12516kb

Test #148:

score: 0
Accepted
time: 40ms
memory: 16672kb

Test #149:

score: 0
Accepted
time: 20ms
memory: 14564kb

Test #150:

score: 0
Accepted
time: 41ms
memory: 16572kb

Test #151:

score: 0
Accepted
time: 45ms
memory: 16496kb

Test #152:

score: 0
Accepted
time: 4ms
memory: 9312kb

Test #153:

score: 0
Accepted
time: 4ms
memory: 7764kb

Test #154:

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

Test #155:

score: 0
Accepted
time: 56ms
memory: 14696kb

Test #156:

score: 0
Accepted
time: 14ms
memory: 9976kb

Test #157:

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

Test #158:

score: 0
Accepted
time: 6ms
memory: 10576kb

Test #159:

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

Test #160:

score: 0
Accepted
time: 4ms
memory: 8936kb

Test #161:

score: 0
Accepted
time: 35ms
memory: 12564kb

Test #162:

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

Test #163:

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

Test #164:

score: 0
Accepted
time: 21ms
memory: 12488kb

Test #165:

score: 0
Accepted
time: 32ms
memory: 14416kb

Test #166:

score: 0
Accepted
time: 51ms
memory: 16656kb