QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#17965#2213. Knight2022zll#AC ✓119ms63280kbC++111.2kb2022-01-15 15:12:152022-05-04 16:32:33

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 16:32:33]
  • 评测
  • 测评结果:AC
  • 用时:119ms
  • 内存:63280kb
  • [2022-01-15 15:12:15]
  • 提交

answer

#include<cstdio>
const int maxn=1005;
int n,m,r,c,sx,sy,tx,ty,*dx,*dy,cnt;
char s[maxn][maxn];
int col[maxn][maxn];
bool vis[maxn][maxn];
void dfs1(int x,int y,int color){
	col[x][y]=color;
	for(int i=0;i<8;i++){
		int x_=x+dx[i],y_=y+dy[i];
		if(x_>=1&&x_<=n&&y_>=1&&y_<=m&&s[x_][y_]!='@'&&!col[x_][y_])dfs1(x_,y_,color^1);
	}
}
bool flag;
void dfs2(int x,int y){
	if(vis[x][y])return;
	vis[x][y]=true;
	for(int i=0;i<8&&!flag;i++){
		int x_=x+dx[i],y_=y+dy[i];
		if(x_==tx&&y_==ty){
			flag=true;
			return;
		}
		if(x_>=1&&x_<=n&&y_>=1&&y_<=m&&s[x_][y_]!='@')dfs2(x_,y_);
	}
}
int main(){
	scanf("%d%d%d%d",&n,&m,&r,&c);
	for(int i=1;i<=n;i++)scanf("%s",s[i]+1);
	int dx_[8]={-r,-c,-c,-r,r,c,c,r},dy_[8]={-c,-r,r,c,c,r,-r,-c};
	dx=dx_,dy=dy_;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			if(s[i][j]!='@'){
				if(!col[i][j])dfs1(i,j,2);
				if(s[i][j]=='A')sx=i,sy=j;
				else if(s[i][j]=='B')tx=i,ty=j;
			}
	for(int i=0;i<8;i++){
		int x_=sx+dx[i],y_=sy+dy[i];
		if(x_>=1&&x_<=n&&y_>=1&&y_<=m&&s[x_][y_]!='@')cnt++;
	}
	if(cnt==0){
		puts("Bob");
		return 0;
	}
	dfs2(sx,sy);
	if(!flag||col[sx][sy]==col[tx][ty])puts("Alice");
	else puts("Bob");
	return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 13ms
memory: 6240kb

Test #2:

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

Test #3:

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

Test #4:

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

Test #5:

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

Test #6:

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

Test #7:

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

Test #8:

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

Test #9:

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

Test #10:

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

Test #11:

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

Test #12:

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

Test #13:

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

Test #14:

score: 0
Accepted
time: 17ms
memory: 6468kb

Test #15:

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

Test #16:

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

Test #17:

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

Test #18:

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

Test #19:

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

Test #20:

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

Test #21:

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

Test #22:

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

Test #23:

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

Test #24:

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

Test #25:

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

Test #26:

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

Test #27:

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

Test #28:

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

Test #29:

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

Test #30:

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

Test #31:

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

Test #32:

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

Test #33:

score: 0
Accepted
time: 34ms
memory: 12280kb

Test #34:

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

Test #35:

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

Test #36:

score: 0
Accepted
time: 36ms
memory: 7484kb

Test #37:

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

Test #38:

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

Test #39:

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

Test #40:

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

Test #41:

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

Test #42:

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

Test #43:

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

Test #44:

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

Test #45:

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

Test #46:

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

Test #47:

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

Test #48:

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

Test #49:

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

Test #50:

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

Test #51:

score: 0
Accepted
time: 73ms
memory: 26768kb

Test #52:

score: 0
Accepted
time: 84ms
memory: 16000kb

Test #53:

score: 0
Accepted
time: 24ms
memory: 6552kb

Test #54:

score: 0
Accepted
time: 82ms
memory: 32676kb

Test #55:

score: 0
Accepted
time: 64ms
memory: 9204kb

Test #56:

score: 0
Accepted
time: 71ms
memory: 40528kb

Test #57:

score: 0
Accepted
time: 83ms
memory: 8904kb

Test #58:

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

Test #59:

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

Test #60:

score: 0
Accepted
time: 105ms
memory: 47404kb

Test #61:

score: 0
Accepted
time: 36ms
memory: 7336kb

Test #62:

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

Test #63:

score: 0
Accepted
time: 78ms
memory: 24656kb

Test #64:

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

Test #65:

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

Test #66:

score: 0
Accepted
time: 24ms
memory: 6836kb

Test #67:

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

Test #68:

score: 0
Accepted
time: 27ms
memory: 7132kb

Test #69:

score: 0
Accepted
time: 106ms
memory: 53852kb

Test #70:

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

Test #71:

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

Test #72:

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

Test #73:

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

Test #74:

score: 0
Accepted
time: 119ms
memory: 43924kb

Test #75:

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

Test #76:

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

Test #77:

score: 0
Accepted
time: 72ms
memory: 31828kb

Test #78:

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

Test #79:

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

Test #80:

score: 0
Accepted
time: 61ms
memory: 9644kb

Test #81:

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

Test #82:

score: 0
Accepted
time: 43ms
memory: 7132kb

Test #83:

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

Test #84:

score: 0
Accepted
time: 34ms
memory: 6596kb

Test #85:

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

Test #86:

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

Test #87:

score: 0
Accepted
time: 17ms
memory: 6576kb

Test #88:

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

Test #89:

score: 0
Accepted
time: 108ms
memory: 43748kb

Test #90:

score: 0
Accepted
time: 44ms
memory: 7568kb

Test #91:

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

Test #92:

score: 0
Accepted
time: 75ms
memory: 18796kb

Test #93:

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

Test #94:

score: 0
Accepted
time: 93ms
memory: 35664kb

Test #95:

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

Test #96:

score: 0
Accepted
time: 38ms
memory: 7680kb

Test #97:

score: 0
Accepted
time: 87ms
memory: 46136kb

Test #98:

score: 0
Accepted
time: 79ms
memory: 28528kb

Test #99:

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

Test #100:

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

Test #101:

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

Test #102:

score: 0
Accepted
time: 43ms
memory: 7696kb

Test #103:

score: 0
Accepted
time: 119ms
memory: 38404kb

Test #104:

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

Test #105:

score: 0
Accepted
time: 64ms
memory: 8864kb

Test #106:

score: 0
Accepted
time: 25ms
memory: 7260kb

Test #107:

score: 0
Accepted
time: 82ms
memory: 32900kb

Test #108:

score: 0
Accepted
time: 101ms
memory: 43696kb

Test #109:

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

Test #110:

score: 0
Accepted
time: 72ms
memory: 26916kb

Test #111:

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

Test #112:

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

Test #113:

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

Test #114:

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

Test #115:

score: 0
Accepted
time: 18ms
memory: 7572kb

Test #116:

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

Test #117:

score: 0
Accepted
time: 75ms
memory: 14136kb

Test #118:

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

Test #119:

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

Test #120:

score: 0
Accepted
time: 63ms
memory: 32596kb

Test #121:

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

Test #122:

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

Test #123:

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

Test #124:

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

Test #125:

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

Test #126:

score: 0
Accepted
time: 18ms
memory: 6604kb

Test #127:

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

Test #128:

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

Test #129:

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

Test #130:

score: 0
Accepted
time: 65ms
memory: 9308kb

Test #131:

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

Test #132:

score: 0
Accepted
time: 54ms
memory: 27412kb

Test #133:

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

Test #134:

score: 0
Accepted
time: 27ms
memory: 6588kb

Test #135:

score: 0
Accepted
time: 91ms
memory: 49660kb

Test #136:

score: 0
Accepted
time: 17ms
memory: 6492kb

Test #137:

score: 0
Accepted
time: 25ms
memory: 7468kb

Test #138:

score: 0
Accepted
time: 92ms
memory: 51728kb

Test #139:

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

Test #140:

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

Test #141:

score: 0
Accepted
time: 83ms
memory: 16288kb

Test #142:

score: 0
Accepted
time: 24ms
memory: 6444kb

Test #143:

score: 0
Accepted
time: 108ms
memory: 53588kb

Test #144:

score: 0
Accepted
time: 57ms
memory: 9920kb

Test #145:

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

Test #146:

score: 0
Accepted
time: 31ms
memory: 7928kb

Test #147:

score: 0
Accepted
time: 81ms
memory: 20848kb

Test #148:

score: 0
Accepted
time: 89ms
memory: 30384kb

Test #149:

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

Test #150:

score: 0
Accepted
time: 67ms
memory: 35724kb

Test #151:

score: 0
Accepted
time: 105ms
memory: 63280kb

Test #152:

score: 0
Accepted
time: 18ms
memory: 7376kb

Test #153:

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

Test #154:

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

Test #155:

score: 0
Accepted
time: 74ms
memory: 38568kb

Test #156:

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

Test #157:

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

Test #158:

score: 0
Accepted
time: 27ms
memory: 6560kb

Test #159:

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

Test #160:

score: 0
Accepted
time: 19ms
memory: 6440kb

Test #161:

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

Test #162:

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

Test #163:

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

Test #164:

score: 0
Accepted
time: 80ms
memory: 14724kb

Test #165:

score: 0
Accepted
time: 66ms
memory: 28660kb

Test #166:

score: 0
Accepted
time: 77ms
memory: 35104kb