QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#17989#2213. KnightA_Pikachu#AC ✓111ms11672kbC++141.2kb2022-01-15 16:39:532022-05-04 16:35:38

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:35:38]
  • 评测
  • 测评结果:AC
  • 用时:111ms
  • 内存:11672kb
  • [2022-01-15 16:39:53]
  • 提交

answer

#include <cstdio>
#include <queue>
using namespace std;
const int N=1005;
int n,m,r,c,xa,ya,xb,yb,cnt,sz[N*N],col[N][N];
int dx[]={-1,-1,1,1,-1,-1,1,1};
int dy[]={-1,1,-1,1,-1,1,-1,1};
char mp[N][N];
int abs(int x){return x<0?-x:x;}
struct node{
	int x,y,t;
};
queue<node> q;
void bfs(int sx,int sy){
	q.push((node){sx,sy,1});
	col[sx][sy]=++cnt;
	sz[cnt]=1;
	while(!q.empty()){
		node tmp=q.front(); q.pop();
		int x=tmp.x,y=tmp.y,t=tmp.t;
		for(int i=0; i<8; i++){
			int xx=x+dx[i],yy=y+dy[i];
			if(xx<1||xx>n||yy<1||yy>m||mp[xx][yy]=='@'||col[xx][yy]) continue;
			col[xx][yy]=-1*t*cnt;
			q.push((node){xx,yy,-1*t});
			++sz[cnt];
		}
	}
}
int main(){
	scanf("%d%d%d%d",&n,&m,&r,&c);
	for(int i=0; i<4; i++) dx[i]*=r,dy[i]*=c;
	for(int i=4; i<8; i++) dx[i]*=c,dy[i]*=r;
	for(int i=1; i<=n; i++){
		for(int j=1; j<=m; j++){
			scanf(" %c",&mp[i][j]);
			if(mp[i][j]=='A') xa=i,ya=j;
			if(mp[i][j]=='B') xb=i,yb=j;
		}
	}
	for(int i=1; i<=n; i++) for(int j=1; j<=m; j++) if(!col[i][j]&&mp[i][j]!='@') bfs(i,j);
	if(abs(col[xa][ya])!=abs(col[xb][yb])){
		if(sz[abs(col[xa][ya])]==1) printf("Bob\n");
		else printf("Alice\n");
	}else{
		if(col[xa][ya]==col[xb][yb]) printf("Alice\n");
		else printf("Bob\n");
	}
	return 0;
}

Details

Test #1:

score: 100
Accepted
time: 37ms
memory: 9800kb

Test #2:

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

Test #3:

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

Test #4:

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

Test #5:

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

Test #6:

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

Test #7:

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

Test #8:

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

Test #9:

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

Test #10:

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

Test #11:

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

Test #12:

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

Test #13:

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

Test #14:

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

Test #15:

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

Test #16:

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

Test #17:

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

Test #18:

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

Test #19:

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

Test #20:

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

Test #21:

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

Test #22:

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

Test #23:

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

Test #24:

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

Test #25:

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

Test #26:

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

Test #27:

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

Test #28:

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

Test #29:

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

Test #30:

score: 0
Accepted
time: 30ms
memory: 11488kb

Test #31:

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

Test #32:

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

Test #33:

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

Test #34:

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

Test #35:

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

Test #36:

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

Test #37:

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

Test #38:

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

Test #39:

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

Test #40:

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

Test #41:

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

Test #42:

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

Test #43:

score: 0
Accepted
time: 37ms
memory: 11564kb

Test #44:

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

Test #45:

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

Test #46:

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

Test #47:

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

Test #48:

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

Test #49:

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

Test #50:

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

Test #51:

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

Test #52:

score: 0
Accepted
time: 99ms
memory: 10004kb

Test #53:

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

Test #54:

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

Test #55:

score: 0
Accepted
time: 88ms
memory: 10024kb

Test #56:

score: 0
Accepted
time: 95ms
memory: 8252kb

Test #57:

score: 0
Accepted
time: 97ms
memory: 9440kb

Test #58:

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

Test #59:

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

Test #60:

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

Test #61:

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

Test #62:

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

Test #63:

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

Test #64:

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

Test #65:

score: 0
Accepted
time: 88ms
memory: 9728kb

Test #66:

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

Test #67:

score: 0
Accepted
time: 103ms
memory: 9016kb

Test #68:

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

Test #69:

score: 0
Accepted
time: 99ms
memory: 8272kb

Test #70:

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

Test #71:

score: 0
Accepted
time: 68ms
memory: 10668kb

Test #72:

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

Test #73:

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

Test #74:

score: 0
Accepted
time: 90ms
memory: 9616kb

Test #75:

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

Test #76:

score: 0
Accepted
time: 111ms
memory: 8900kb

Test #77:

score: 0
Accepted
time: 95ms
memory: 8072kb

Test #78:

score: 0
Accepted
time: 59ms
memory: 9900kb

Test #79:

score: 0
Accepted
time: 69ms
memory: 9168kb

Test #80:

score: 0
Accepted
time: 98ms
memory: 9004kb

Test #81:

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

Test #82:

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

Test #83:

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

Test #84:

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

Test #85:

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

Test #86:

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

Test #87:

score: 0
Accepted
time: 68ms
memory: 11092kb

Test #88:

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

Test #89:

score: 0
Accepted
time: 86ms
memory: 8916kb

Test #90:

score: 0
Accepted
time: 95ms
memory: 9196kb

Test #91:

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

Test #92:

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

Test #93:

score: 0
Accepted
time: 55ms
memory: 9904kb

Test #94:

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

Test #95:

score: 0
Accepted
time: 90ms
memory: 8052kb

Test #96:

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

Test #97:

score: 0
Accepted
time: 104ms
memory: 8868kb

Test #98:

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

Test #99:

score: 0
Accepted
time: 107ms
memory: 8920kb

Test #100:

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

Test #101:

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

Test #102:

score: 0
Accepted
time: 85ms
memory: 9448kb

Test #103:

score: 0
Accepted
time: 107ms
memory: 8676kb

Test #104:

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

Test #105:

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

Test #106:

score: 0
Accepted
time: 70ms
memory: 9104kb

Test #107:

score: 0
Accepted
time: 95ms
memory: 10152kb

Test #108:

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

Test #109:

score: 0
Accepted
time: 102ms
memory: 8688kb

Test #110:

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

Test #111:

score: 0
Accepted
time: 102ms
memory: 9024kb

Test #112:

score: 0
Accepted
time: 100ms
memory: 9000kb

Test #113:

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

Test #114:

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

Test #115:

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

Test #116:

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

Test #117:

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

Test #118:

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

Test #119:

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

Test #120:

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

Test #121:

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

Test #122:

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

Test #123:

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

Test #124:

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

Test #125:

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

Test #126:

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

Test #127:

score: 0
Accepted
time: 55ms
memory: 9748kb

Test #128:

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

Test #129:

score: 0
Accepted
time: 55ms
memory: 10144kb

Test #130:

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

Test #131:

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

Test #132:

score: 0
Accepted
time: 96ms
memory: 9996kb

Test #133:

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

Test #134:

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

Test #135:

score: 0
Accepted
time: 99ms
memory: 9064kb

Test #136:

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

Test #137:

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

Test #138:

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

Test #139:

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

Test #140:

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

Test #141:

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

Test #142:

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

Test #143:

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

Test #144:

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

Test #145:

score: 0
Accepted
time: 98ms
memory: 8720kb

Test #146:

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

Test #147:

score: 0
Accepted
time: 97ms
memory: 9712kb

Test #148:

score: 0
Accepted
time: 96ms
memory: 8920kb

Test #149:

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

Test #150:

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

Test #151:

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

Test #152:

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

Test #153:

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

Test #154:

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

Test #155:

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

Test #156:

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

Test #157:

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

Test #158:

score: 0
Accepted
time: 76ms
memory: 8920kb

Test #159:

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

Test #160:

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

Test #161:

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

Test #162:

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

Test #163:

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

Test #164:

score: 0
Accepted
time: 102ms
memory: 9824kb

Test #165:

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

Test #166:

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