QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#17919#2213. Knightqingyu_orzAC ✓765ms130796kbC++141.2kb2022-01-15 12:14:482022-05-04 16:19:39

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:19:39]
  • 评测
  • 测评结果:AC
  • 用时:765ms
  • 内存:130796kb
  • [2022-01-15 12:14:48]
  • 提交

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: 68ms
memory: 43228kb

Test #2:

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

Test #3:

score: 0
Accepted
time: 302ms
memory: 61264kb

Test #4:

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

Test #5:

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

Test #6:

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

Test #7:

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

Test #8:

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

Test #9:

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

Test #10:

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

Test #11:

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

Test #12:

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

Test #13:

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

Test #14:

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

Test #15:

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

Test #16:

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

Test #17:

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

Test #18:

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

Test #19:

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

Test #20:

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

Test #21:

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

Test #22:

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

Test #23:

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

Test #24:

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

Test #25:

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

Test #26:

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

Test #27:

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

Test #28:

score: 0
Accepted
time: 247ms
memory: 63964kb

Test #29:

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

Test #30:

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

Test #31:

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

Test #32:

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

Test #33:

score: 0
Accepted
time: 269ms
memory: 55444kb

Test #34:

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

Test #35:

score: 0
Accepted
time: 238ms
memory: 54488kb

Test #36:

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

Test #37:

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

Test #38:

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

Test #39:

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

Test #40:

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

Test #41:

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

Test #42:

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

Test #43:

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

Test #44:

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

Test #45:

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

Test #46:

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

Test #47:

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

Test #48:

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

Test #49:

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

Test #50:

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

Test #51:

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

Test #52:

score: 0
Accepted
time: 570ms
memory: 80436kb

Test #53:

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

Test #54:

score: 0
Accepted
time: 695ms
memory: 111952kb

Test #55:

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

Test #56:

score: 0
Accepted
time: 699ms
memory: 104612kb

Test #57:

score: 0
Accepted
time: 291ms
memory: 53356kb

Test #58:

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

Test #59:

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

Test #60:

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

Test #61:

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

Test #62:

score: 0
Accepted
time: 191ms
memory: 43572kb

Test #63:

score: 0
Accepted
time: 507ms
memory: 81028kb

Test #64:

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

Test #65:

score: 0
Accepted
time: 765ms
memory: 105952kb

Test #66:

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

Test #67:

score: 0
Accepted
time: 362ms
memory: 61488kb

Test #68:

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

Test #69:

score: 0
Accepted
time: 753ms
memory: 114276kb

Test #70:

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

Test #71:

score: 0
Accepted
time: 138ms
memory: 46480kb

Test #72:

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

Test #73:

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

Test #74:

score: 0
Accepted
time: 661ms
memory: 106660kb

Test #75:

score: 0
Accepted
time: 291ms
memory: 58804kb

Test #76:

score: 0
Accepted
time: 380ms
memory: 63392kb

Test #77:

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

Test #78:

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

Test #79:

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

Test #80:

score: 0
Accepted
time: 310ms
memory: 60012kb

Test #81:

score: 0
Accepted
time: 283ms
memory: 57612kb

Test #82:

score: 0
Accepted
time: 299ms
memory: 55324kb

Test #83:

score: 0
Accepted
time: 147ms
memory: 50540kb

Test #84:

score: 0
Accepted
time: 142ms
memory: 42212kb

Test #85:

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

Test #86:

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

Test #87:

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

Test #88:

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

Test #89:

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

Test #90:

score: 0
Accepted
time: 300ms
memory: 55904kb

Test #91:

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

Test #92:

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

Test #93:

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

Test #94:

score: 0
Accepted
time: 604ms
memory: 95092kb

Test #95:

score: 0
Accepted
time: 496ms
memory: 94744kb

Test #96:

score: 0
Accepted
time: 336ms
memory: 61332kb

Test #97:

score: 0
Accepted
time: 574ms
memory: 101428kb

Test #98:

score: 0
Accepted
time: 510ms
memory: 81964kb

Test #99:

score: 0
Accepted
time: 472ms
memory: 78608kb

Test #100:

score: 0
Accepted
time: 529ms
memory: 89972kb

Test #101:

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

Test #102:

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

Test #103:

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

Test #104:

score: 0
Accepted
time: 198ms
memory: 44112kb

Test #105:

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

Test #106:

score: 0
Accepted
time: 195ms
memory: 53540kb

Test #107:

score: 0
Accepted
time: 520ms
memory: 90760kb

Test #108:

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

Test #109:

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

Test #110:

score: 0
Accepted
time: 665ms
memory: 98364kb

Test #111:

score: 0
Accepted
time: 376ms
memory: 68160kb

Test #112:

score: 0
Accepted
time: 592ms
memory: 92416kb

Test #113:

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

Test #114:

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

Test #115:

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

Test #116:

score: 0
Accepted
time: 543ms
memory: 93392kb

Test #117:

score: 0
Accepted
time: 666ms
memory: 108048kb

Test #118:

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

Test #119:

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

Test #120:

score: 0
Accepted
time: 405ms
memory: 78092kb

Test #121:

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

Test #122:

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

Test #123:

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

Test #124:

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

Test #125:

score: 0
Accepted
time: 251ms
memory: 51888kb

Test #126:

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

Test #127:

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

Test #128:

score: 0
Accepted
time: 154ms
memory: 56452kb

Test #129:

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

Test #130:

score: 0
Accepted
time: 474ms
memory: 75772kb

Test #131:

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

Test #132:

score: 0
Accepted
time: 373ms
memory: 67680kb

Test #133:

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

Test #134:

score: 0
Accepted
time: 138ms
memory: 46504kb

Test #135:

score: 0
Accepted
time: 685ms
memory: 108872kb

Test #136:

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

Test #137:

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

Test #138:

score: 0
Accepted
time: 593ms
memory: 115168kb

Test #139:

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

Test #140:

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

Test #141:

score: 0
Accepted
time: 649ms
memory: 91360kb

Test #142:

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

Test #143:

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

Test #144:

score: 0
Accepted
time: 328ms
memory: 59728kb

Test #145:

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

Test #146:

score: 0
Accepted
time: 181ms
memory: 45380kb

Test #147:

score: 0
Accepted
time: 720ms
memory: 111084kb

Test #148:

score: 0
Accepted
time: 696ms
memory: 92528kb

Test #149:

score: 0
Accepted
time: 381ms
memory: 66572kb

Test #150:

score: 0
Accepted
time: 574ms
memory: 97916kb

Test #151:

score: 0
Accepted
time: 693ms
memory: 130796kb

Test #152:

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

Test #153:

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

Test #154:

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

Test #155:

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

Test #156:

score: 0
Accepted
time: 118ms
memory: 44760kb

Test #157:

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

Test #158:

score: 0
Accepted
time: 212ms
memory: 52980kb

Test #159:

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

Test #160:

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

Test #161:

score: 0
Accepted
time: 191ms
memory: 48556kb

Test #162:

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

Test #163:

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

Test #164:

score: 0
Accepted
time: 360ms
memory: 65028kb

Test #165:

score: 0
Accepted
time: 713ms
memory: 103520kb

Test #166:

score: 0
Accepted
time: 528ms
memory: 84852kb