QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#17926#2213. Knightqingyu_orzAC ✓769ms130712kbC++141.3kb2022-01-15 12:29:472022-05-04 16:24:53

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:24:53]
  • 评测
  • 测评结果:AC
  • 用时:769ms
  • 内存:130712kb
  • [2022-01-15 12:29:47]
  • 提交

answer

#include<bits/stdc++.h>
#define mk(x,y) ((x-1)*m+y)
using namespace std;
char s[1005][1005];
vector<int>g[1000005];
int mb[8][2];
int col[1000005];
void dfs(int x){
	for(auto cu:g[x]){
		if(col[cu]){
			continue;
		}
		col[cu]=-col[x];
		dfs(cu);
	}
}
int main(){
	int n,m,x,y;
	cin>>n>>m>>x>>y;
	for(int i=1;i<=n;++i)scanf("%s",s[i]+1);
	mb[0][0]=x,mb[0][1]=y;
	mb[1][0]=-x,mb[1][1]=y;
	mb[2][0]=x,mb[2][1]=-y;
	mb[3][0]=-x,mb[3][1]=-y;
	mb[4][0]=y,mb[4][1]=x;
	mb[5][0]=-y,mb[5][1]=x;
	mb[6][0]=y,mb[6][1]=-x;
	mb[7][0]=-y,mb[7][1]=-x;
	for(int i=1;i<=n;++i)for(int j=1;j<=m;++j)
		if(s[i][j]!='@'){
			for(int k=0;k<8;++k){
				int dx=i+mb[k][0],dy=j+mb[k][1];
				if(dx<1||dy<1||dx>n||dy>m)continue;
				if(s[dx][dy]=='@')continue;
				int u=mk(i,j),v=mk(dx,dy);
				g[u].emplace_back(v);
				g[v].emplace_back(u);
			}
		}
	int A=-1,B=-1;
	for(int i=1;i<=n;++i)for(int j=1;j<=m;++j){
		if(s[i][j]=='A')A=mk(i,j);
		else if(s[i][j]=='B')B=mk(i,j);
	}
	if(A==-1||B==-1)while(1);
	if(!g[A].size()||g[A][0]==B){
		puts("Bob");
		return 0;
	}
	int N=mk(n,m);
	for(int i=1;i<=N;++i)if(!col[i]){
		col[i]=i;
		dfs(i);
	}
	if(abs(col[A])!=abs(col[B]))puts("Alice");
	else if(col[A]==col[B])puts("Alice");
	else puts("Bob");
	return 0;
}

详细

Test #1:

score: 100
Accepted
time: 63ms
memory: 43636kb

Test #2:

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

Test #3:

score: 0
Accepted
time: 249ms
memory: 61380kb

Test #4:

score: 0
Accepted
time: 112ms
memory: 44512kb

Test #5:

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

Test #6:

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

Test #7:

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

Test #8:

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

Test #9:

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

Test #10:

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

Test #11:

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

Test #12:

score: 0
Accepted
time: 123ms
memory: 51180kb

Test #13:

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

Test #14:

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

Test #15:

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

Test #16:

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

Test #17:

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

Test #18:

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

Test #19:

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

Test #20:

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

Test #21:

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

Test #22:

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

Test #23:

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

Test #24:

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

Test #25:

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

Test #26:

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

Test #27:

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

Test #28:

score: 0
Accepted
time: 151ms
memory: 63944kb

Test #29:

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

Test #30:

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

Test #31:

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

Test #32:

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

Test #33:

score: 0
Accepted
time: 192ms
memory: 55492kb

Test #34:

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

Test #35:

score: 0
Accepted
time: 178ms
memory: 54492kb

Test #36:

score: 0
Accepted
time: 240ms
memory: 54812kb

Test #37:

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

Test #38:

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

Test #39:

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

Test #40:

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

Test #41:

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

Test #42:

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

Test #43:

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

Test #44:

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

Test #45:

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

Test #46:

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

Test #47:

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

Test #48:

score: 0
Accepted
time: 249ms
memory: 49564kb

Test #49:

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

Test #50:

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

Test #51:

score: 0
Accepted
time: 509ms
memory: 76852kb

Test #52:

score: 0
Accepted
time: 494ms
memory: 80464kb

Test #53:

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

Test #54:

score: 0
Accepted
time: 625ms
memory: 112004kb

Test #55:

score: 0
Accepted
time: 304ms
memory: 54316kb

Test #56:

score: 0
Accepted
time: 654ms
memory: 104764kb

Test #57:

score: 0
Accepted
time: 271ms
memory: 53304kb

Test #58:

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

Test #59:

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

Test #60:

score: 0
Accepted
time: 686ms
memory: 108948kb

Test #61:

score: 0
Accepted
time: 235ms
memory: 50912kb

Test #62:

score: 0
Accepted
time: 176ms
memory: 43548kb

Test #63:

score: 0
Accepted
time: 481ms
memory: 81040kb

Test #64:

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

Test #65:

score: 0
Accepted
time: 628ms
memory: 105908kb

Test #66:

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

Test #67:

score: 0
Accepted
time: 334ms
memory: 61564kb

Test #68:

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

Test #69:

score: 0
Accepted
time: 718ms
memory: 114160kb

Test #70:

score: 0
Accepted
time: 202ms
memory: 46044kb

Test #71:

score: 0
Accepted
time: 180ms
memory: 46484kb

Test #72:

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

Test #73:

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

Test #74:

score: 0
Accepted
time: 703ms
memory: 106548kb

Test #75:

score: 0
Accepted
time: 311ms
memory: 58808kb

Test #76:

score: 0
Accepted
time: 379ms
memory: 63232kb

Test #77:

score: 0
Accepted
time: 537ms
memory: 92156kb

Test #78:

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

Test #79:

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

Test #80:

score: 0
Accepted
time: 312ms
memory: 59816kb

Test #81:

score: 0
Accepted
time: 290ms
memory: 57412kb

Test #82:

score: 0
Accepted
time: 327ms
memory: 55320kb

Test #83:

score: 0
Accepted
time: 127ms
memory: 50264kb

Test #84:

score: 0
Accepted
time: 149ms
memory: 42140kb

Test #85:

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

Test #86:

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

Test #87:

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

Test #88:

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

Test #89:

score: 0
Accepted
time: 718ms
memory: 106704kb

Test #90:

score: 0
Accepted
time: 306ms
memory: 55900kb

Test #91:

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

Test #92:

score: 0
Accepted
time: 739ms
memory: 97664kb

Test #93:

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

Test #94:

score: 0
Accepted
time: 640ms
memory: 95172kb

Test #95:

score: 0
Accepted
time: 530ms
memory: 94944kb

Test #96:

score: 0
Accepted
time: 345ms
memory: 61256kb

Test #97:

score: 0
Accepted
time: 548ms
memory: 101264kb

Test #98:

score: 0
Accepted
time: 438ms
memory: 81960kb

Test #99:

score: 0
Accepted
time: 465ms
memory: 78748kb

Test #100:

score: 0
Accepted
time: 549ms
memory: 89968kb

Test #101:

score: 0
Accepted
time: 731ms
memory: 104720kb

Test #102:

score: 0
Accepted
time: 575ms
memory: 101164kb

Test #103:

score: 0
Accepted
time: 600ms
memory: 96000kb

Test #104:

score: 0
Accepted
time: 202ms
memory: 44140kb

Test #105:

score: 0
Accepted
time: 442ms
memory: 77588kb

Test #106:

score: 0
Accepted
time: 199ms
memory: 53632kb

Test #107:

score: 0
Accepted
time: 559ms
memory: 90624kb

Test #108:

score: 0
Accepted
time: 703ms
memory: 108692kb

Test #109:

score: 0
Accepted
time: 375ms
memory: 66684kb

Test #110:

score: 0
Accepted
time: 698ms
memory: 98368kb

Test #111:

score: 0
Accepted
time: 436ms
memory: 68172kb

Test #112:

score: 0
Accepted
time: 642ms
memory: 92508kb

Test #113:

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

Test #114:

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

Test #115:

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

Test #116:

score: 0
Accepted
time: 573ms
memory: 93412kb

Test #117:

score: 0
Accepted
time: 691ms
memory: 108032kb

Test #118:

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

Test #119:

score: 0
Accepted
time: 29ms
memory: 32084kb

Test #120:

score: 0
Accepted
time: 393ms
memory: 78096kb

Test #121:

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

Test #122:

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

Test #123:

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

Test #124:

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

Test #125:

score: 0
Accepted
time: 267ms
memory: 51932kb

Test #126:

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

Test #127:

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

Test #128:

score: 0
Accepted
time: 149ms
memory: 56672kb

Test #129:

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

Test #130:

score: 0
Accepted
time: 550ms
memory: 75788kb

Test #131:

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

Test #132:

score: 0
Accepted
time: 364ms
memory: 67704kb

Test #133:

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

Test #134:

score: 0
Accepted
time: 161ms
memory: 46500kb

Test #135:

score: 0
Accepted
time: 715ms
memory: 108912kb

Test #136:

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

Test #137:

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

Test #138:

score: 0
Accepted
time: 654ms
memory: 115136kb

Test #139:

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

Test #140:

score: 0
Accepted
time: 146ms
memory: 48944kb

Test #141:

score: 0
Accepted
time: 671ms
memory: 91264kb

Test #142:

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

Test #143:

score: 0
Accepted
time: 733ms
memory: 115172kb

Test #144:

score: 0
Accepted
time: 372ms
memory: 59608kb

Test #145:

score: 0
Accepted
time: 349ms
memory: 74068kb

Test #146:

score: 0
Accepted
time: 203ms
memory: 45360kb

Test #147:

score: 0
Accepted
time: 769ms
memory: 111096kb

Test #148:

score: 0
Accepted
time: 618ms
memory: 92612kb

Test #149:

score: 0
Accepted
time: 379ms
memory: 66576kb

Test #150:

score: 0
Accepted
time: 559ms
memory: 97976kb

Test #151:

score: 0
Accepted
time: 627ms
memory: 130712kb

Test #152:

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

Test #153:

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

Test #154:

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

Test #155:

score: 0
Accepted
time: 579ms
memory: 88776kb

Test #156:

score: 0
Accepted
time: 123ms
memory: 44564kb

Test #157:

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

Test #158:

score: 0
Accepted
time: 232ms
memory: 52912kb

Test #159:

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

Test #160:

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

Test #161:

score: 0
Accepted
time: 211ms
memory: 48636kb

Test #162:

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

Test #163:

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

Test #164:

score: 0
Accepted
time: 363ms
memory: 65104kb

Test #165:

score: 0
Accepted
time: 754ms
memory: 103660kb

Test #166:

score: 0
Accepted
time: 511ms
memory: 84760kb