QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#17923#2213. Knightqingyu_orzAC ✓863ms130660kbC++141.3kb2022-01-15 12:26:352022-05-04 16:22:21

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:22:21]
  • 评测
  • 测评结果:AC
  • 用时:863ms
  • 内存:130660kb
  • [2022-01-15 12:26: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]){
			assert(col[x]+col[cu]==0);
			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()||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;
}

Details

Test #1:

score: 100
Accepted
time: 54ms
memory: 43296kb

Test #2:

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

Test #3:

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

Test #4:

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

Test #5:

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

Test #6:

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

Test #7:

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

Test #8:

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

Test #9:

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

Test #10:

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

Test #11:

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

Test #12:

score: 0
Accepted
time: 145ms
memory: 51104kb

Test #13:

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

Test #14:

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

Test #15:

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

Test #16:

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

Test #17:

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

Test #18:

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

Test #19:

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

Test #20:

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

Test #21:

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

Test #22:

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

Test #23:

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

Test #24:

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

Test #25:

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

Test #26:

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

Test #27:

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

Test #28:

score: 0
Accepted
time: 183ms
memory: 61800kb

Test #29:

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

Test #30:

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

Test #31:

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

Test #32:

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

Test #33:

score: 0
Accepted
time: 204ms
memory: 55488kb

Test #34:

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

Test #35:

score: 0
Accepted
time: 183ms
memory: 54572kb

Test #36:

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

Test #37:

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

Test #38:

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

Test #39:

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

Test #40:

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

Test #41:

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

Test #42:

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

Test #43:

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

Test #44:

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

Test #45:

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

Test #46:

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

Test #47:

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

Test #48:

score: 0
Accepted
time: 224ms
memory: 49548kb

Test #49:

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

Test #50:

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

Test #51:

score: 0
Accepted
time: 503ms
memory: 76728kb

Test #52:

score: 0
Accepted
time: 506ms
memory: 80444kb

Test #53:

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

Test #54:

score: 0
Accepted
time: 636ms
memory: 111916kb

Test #55:

score: 0
Accepted
time: 289ms
memory: 54208kb

Test #56:

score: 0
Accepted
time: 646ms
memory: 104560kb

Test #57:

score: 0
Accepted
time: 258ms
memory: 53160kb

Test #58:

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

Test #59:

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

Test #60:

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

Test #61:

score: 0
Accepted
time: 250ms
memory: 50768kb

Test #62:

score: 0
Accepted
time: 163ms
memory: 43628kb

Test #63:

score: 0
Accepted
time: 471ms
memory: 80824kb

Test #64:

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

Test #65:

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

Test #66:

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

Test #67:

score: 0
Accepted
time: 355ms
memory: 61636kb

Test #68:

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

Test #69:

score: 0
Accepted
time: 663ms
memory: 114212kb

Test #70:

score: 0
Accepted
time: 189ms
memory: 45928kb

Test #71:

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

Test #72:

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

Test #73:

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

Test #74:

score: 0
Accepted
time: 652ms
memory: 106580kb

Test #75:

score: 0
Accepted
time: 279ms
memory: 58716kb

Test #76:

score: 0
Accepted
time: 355ms
memory: 63272kb

Test #77:

score: 0
Accepted
time: 506ms
memory: 92260kb

Test #78:

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

Test #79:

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

Test #80:

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

Test #81:

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

Test #82:

score: 0
Accepted
time: 280ms
memory: 55300kb

Test #83:

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

Test #84:

score: 0
Accepted
time: 113ms
memory: 42288kb

Test #85:

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

Test #86:

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

Test #87:

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

Test #88:

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

Test #89:

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

Test #90:

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

Test #91:

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

Test #92:

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

Test #93:

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

Test #94:

score: 0
Accepted
time: 557ms
memory: 95260kb

Test #95:

score: 0
Accepted
time: 398ms
memory: 94748kb

Test #96:

score: 0
Accepted
time: 289ms
memory: 61384kb

Test #97:

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

Test #98:

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

Test #99:

score: 0
Accepted
time: 446ms
memory: 78732kb

Test #100:

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

Test #101:

score: 0
Accepted
time: 590ms
memory: 104632kb

Test #102:

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

Test #103:

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

Test #104:

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

Test #105:

score: 0
Accepted
time: 409ms
memory: 77632kb

Test #106:

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

Test #107:

score: 0
Accepted
time: 508ms
memory: 90668kb

Test #108:

score: 0
Accepted
time: 772ms
memory: 108556kb

Test #109:

score: 0
Accepted
time: 388ms
memory: 66536kb

Test #110:

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

Test #111:

score: 0
Accepted
time: 426ms
memory: 68080kb

Test #112:

score: 0
Accepted
time: 687ms
memory: 92488kb

Test #113:

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

Test #114:

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

Test #115:

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

Test #116:

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

Test #117:

score: 0
Accepted
time: 863ms
memory: 107880kb

Test #118:

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

Test #119:

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

Test #120:

score: 0
Accepted
time: 452ms
memory: 77984kb

Test #121:

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

Test #122:

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

Test #123:

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

Test #124:

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

Test #125:

score: 0
Accepted
time: 273ms
memory: 51940kb

Test #126:

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

Test #127:

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

Test #128:

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

Test #129:

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

Test #130:

score: 0
Accepted
time: 519ms
memory: 75768kb

Test #131:

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

Test #132:

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

Test #133:

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

Test #134:

score: 0
Accepted
time: 175ms
memory: 46448kb

Test #135:

score: 0
Accepted
time: 827ms
memory: 108920kb

Test #136:

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

Test #137:

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

Test #138:

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

Test #139:

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

Test #140:

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

Test #141:

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

Test #142:

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

Test #143:

score: 0
Accepted
time: 789ms
memory: 115300kb

Test #144:

score: 0
Accepted
time: 354ms
memory: 59648kb

Test #145:

score: 0
Accepted
time: 361ms
memory: 73852kb

Test #146:

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

Test #147:

score: 0
Accepted
time: 758ms
memory: 111016kb

Test #148:

score: 0
Accepted
time: 594ms
memory: 92420kb

Test #149:

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

Test #150:

score: 0
Accepted
time: 542ms
memory: 98000kb

Test #151:

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

Test #152:

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

Test #153:

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

Test #154:

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

Test #155:

score: 0
Accepted
time: 546ms
memory: 88668kb

Test #156:

score: 0
Accepted
time: 121ms
memory: 44680kb

Test #157:

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

Test #158:

score: 0
Accepted
time: 215ms
memory: 52948kb

Test #159:

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

Test #160:

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

Test #161:

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

Test #162:

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

Test #163:

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

Test #164:

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

Test #165:

score: 0
Accepted
time: 763ms
memory: 103720kb

Test #166:

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