QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#18141#2213. KnightWu_Ren#WA 80ms30948kbC++111.1kb2022-01-16 15:07:582022-05-04 17:11:52

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 17:11:52]
  • 评测
  • 测评结果:WA
  • 用时:80ms
  • 内存:30948kb
  • [2022-01-16 15:07:58]
  • 提交

answer

#include<bits/stdc++.h>
int mod;
#define id(a,b) (((a)-1)*m+(b))
using namespace std;
int n,m,K,alice,bob,r,c;
int head[1000010],o=0,cnt=0,vis[1000010];
char s[1010][1010];
struct edge{
	int to,link;
}e[8000010];
void add_edge(int u,int v){
	e[++o]=(edge){v,head[u]},head[u]=o;
	e[++o]=(edge){u,head[v]},head[v]=o;
}
void dfs(int u,int c){
	vis[u]=c;
	for(int i=head[u];i;i=e[i].link) if(!vis[e[i].to]) dfs(e[i].to,-c);
}
int main(){
	scanf("%d%d%d%d",&n,&m,&r,&c);
	int fx[][2]={{r,c},{r,-c},{c,r},{c,-r}};
	for(int i=1;i<=n;i++) scanf("%s",s[i]+1);
	for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) if(s[i][j]!='@'){
		for(int k=0;k<4;k++){
			int x=i+fx[k][0],y=j+fx[k][1];
			if(1<=x&&x<=n&&1<=y&&y<=m&&s[x][y]!='@') add_edge(id(i,j),id(x,y));
		}
	}
	for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) if(!vis[id(i,j)]){
		if(s[i][j]=='A'||s[i][j]=='B') dfs(id(i,j),++cnt);
		if(s[i][j]=='A') alice=id(i,j);
		if(s[i][j]=='B') bob=id(i,j);
	}
	if(!head[alice]) puts("Bob"),exit(0);
	if(abs(vis[alice])!=abs(vis[bob])||vis[alice]==vis[bob]) puts("Alice");
	else puts("Bob"); 
}

详细

Test #1:

score: 100
Accepted
time: 5ms
memory: 18584kb

Test #2:

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

Test #3:

score: 0
Accepted
time: 80ms
memory: 30948kb

Test #4:

score: -100
Wrong Answer
time: 28ms
memory: 18688kb