QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#17925#2213. Knightqingyu_orzAC ✓715ms130800kbC++141.2kb2022-01-15 12:27:352022-05-04 16:24:03

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:03]
  • 评测
  • 测评结果:AC
  • 用时:715ms
  • 内存:130800kb
  • [2022-01-15 12:27:35]
  • 提交

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(!g[A].size()){
		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;
}

Details

Test #1:

score: 100
Accepted
time: 58ms
memory: 43408kb

Test #2:

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

Test #3:

score: 0
Accepted
time: 263ms
memory: 61172kb

Test #4:

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

Test #5:

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

Test #6:

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

Test #7:

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

Test #8:

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

Test #9:

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

Test #10:

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

Test #11:

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

Test #12:

score: 0
Accepted
time: 150ms
memory: 51208kb

Test #13:

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

Test #14:

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

Test #15:

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

Test #16:

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

Test #17:

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

Test #18:

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

Test #19:

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

Test #20:

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

Test #21:

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

Test #22:

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

Test #23:

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

Test #24:

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

Test #25:

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

Test #26:

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

Test #27:

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

Test #28:

score: 0
Accepted
time: 174ms
memory: 63904kb

Test #29:

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

Test #30:

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

Test #31:

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

Test #32:

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

Test #33:

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

Test #34:

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

Test #35:

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

Test #36:

score: 0
Accepted
time: 257ms
memory: 54928kb

Test #37:

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

Test #38:

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

Test #39:

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

Test #40:

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

Test #41:

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

Test #42:

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

Test #43:

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

Test #44:

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

Test #45:

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

Test #46:

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

Test #47:

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

Test #48:

score: 0
Accepted
time: 236ms
memory: 49540kb

Test #49:

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

Test #50:

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

Test #51:

score: 0
Accepted
time: 504ms
memory: 76732kb

Test #52:

score: 0
Accepted
time: 466ms
memory: 80316kb

Test #53:

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

Test #54:

score: 0
Accepted
time: 621ms
memory: 111948kb

Test #55:

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

Test #56:

score: 0
Accepted
time: 605ms
memory: 104692kb

Test #57:

score: 0
Accepted
time: 241ms
memory: 53372kb

Test #58:

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

Test #59:

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

Test #60:

score: 0
Accepted
time: 672ms
memory: 108952kb

Test #61:

score: 0
Accepted
time: 222ms
memory: 50844kb

Test #62:

score: 0
Accepted
time: 168ms
memory: 43624kb

Test #63:

score: 0
Accepted
time: 469ms
memory: 80944kb

Test #64:

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

Test #65:

score: 0
Accepted
time: 643ms
memory: 106004kb

Test #66:

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

Test #67:

score: 0
Accepted
time: 352ms
memory: 61368kb

Test #68:

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

Test #69:

score: 0
Accepted
time: 637ms
memory: 114008kb

Test #70:

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

Test #71:

score: 0
Accepted
time: 156ms
memory: 46352kb

Test #72:

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

Test #73:

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

Test #74:

score: 0
Accepted
time: 660ms
memory: 106636kb

Test #75:

score: 0
Accepted
time: 284ms
memory: 58744kb

Test #76:

score: 0
Accepted
time: 374ms
memory: 63368kb

Test #77:

score: 0
Accepted
time: 515ms
memory: 92108kb

Test #78:

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

Test #79:

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

Test #80:

score: 0
Accepted
time: 292ms
memory: 60020kb

Test #81:

score: 0
Accepted
time: 265ms
memory: 57524kb

Test #82:

score: 0
Accepted
time: 309ms
memory: 55384kb

Test #83:

score: 0
Accepted
time: 141ms
memory: 49644kb

Test #84:

score: 0
Accepted
time: 120ms
memory: 42020kb

Test #85:

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

Test #86:

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

Test #87:

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

Test #88:

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

Test #89:

score: 0
Accepted
time: 584ms
memory: 106644kb

Test #90:

score: 0
Accepted
time: 287ms
memory: 55932kb

Test #91:

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

Test #92:

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

Test #93:

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

Test #94:

score: 0
Accepted
time: 581ms
memory: 95280kb

Test #95:

score: 0
Accepted
time: 443ms
memory: 94900kb

Test #96:

score: 0
Accepted
time: 287ms
memory: 61308kb

Test #97:

score: 0
Accepted
time: 493ms
memory: 101156kb

Test #98:

score: 0
Accepted
time: 427ms
memory: 82104kb

Test #99:

score: 0
Accepted
time: 457ms
memory: 78716kb

Test #100:

score: 0
Accepted
time: 487ms
memory: 89888kb

Test #101:

score: 0
Accepted
time: 639ms
memory: 104724kb

Test #102:

score: 0
Accepted
time: 552ms
memory: 101168kb

Test #103:

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

Test #104:

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

Test #105:

score: 0
Accepted
time: 410ms
memory: 77592kb

Test #106:

score: 0
Accepted
time: 187ms
memory: 53500kb

Test #107:

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

Test #108:

score: 0
Accepted
time: 601ms
memory: 108760kb

Test #109:

score: 0
Accepted
time: 366ms
memory: 66612kb

Test #110:

score: 0
Accepted
time: 678ms
memory: 98284kb

Test #111:

score: 0
Accepted
time: 387ms
memory: 68164kb

Test #112:

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

Test #113:

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

Test #114:

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

Test #115:

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

Test #116:

score: 0
Accepted
time: 567ms
memory: 93472kb

Test #117:

score: 0
Accepted
time: 688ms
memory: 107876kb

Test #118:

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

Test #119:

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

Test #120:

score: 0
Accepted
time: 403ms
memory: 78180kb

Test #121:

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

Test #122:

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

Test #123:

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

Test #124:

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

Test #125:

score: 0
Accepted
time: 236ms
memory: 51928kb

Test #126:

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

Test #127:

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

Test #128:

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

Test #129:

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

Test #130:

score: 0
Accepted
time: 461ms
memory: 75796kb

Test #131:

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

Test #132:

score: 0
Accepted
time: 335ms
memory: 67772kb

Test #133:

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

Test #134:

score: 0
Accepted
time: 152ms
memory: 46576kb

Test #135:

score: 0
Accepted
time: 660ms
memory: 108712kb

Test #136:

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

Test #137:

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

Test #138:

score: 0
Accepted
time: 596ms
memory: 115148kb

Test #139:

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

Test #140:

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

Test #141:

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

Test #142:

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

Test #143:

score: 0
Accepted
time: 647ms
memory: 115232kb

Test #144:

score: 0
Accepted
time: 313ms
memory: 59652kb

Test #145:

score: 0
Accepted
time: 338ms
memory: 73996kb

Test #146:

score: 0
Accepted
time: 159ms
memory: 45368kb

Test #147:

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

Test #148:

score: 0
Accepted
time: 522ms
memory: 92616kb

Test #149:

score: 0
Accepted
time: 335ms
memory: 66652kb

Test #150:

score: 0
Accepted
time: 580ms
memory: 97968kb

Test #151:

score: 0
Accepted
time: 623ms
memory: 130800kb

Test #152:

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

Test #153:

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

Test #154:

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

Test #155:

score: 0
Accepted
time: 500ms
memory: 88740kb

Test #156:

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

Test #157:

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

Test #158:

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

Test #159:

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

Test #160:

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

Test #161:

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

Test #162:

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

Test #163:

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

Test #164:

score: 0
Accepted
time: 344ms
memory: 65120kb

Test #165:

score: 0
Accepted
time: 711ms
memory: 103728kb

Test #166:

score: 0
Accepted
time: 489ms
memory: 84716kb