QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#17928#2213. KnightCharlieVinnie#WA 45ms47664kbC++141.3kb2022-01-15 12:33:382022-05-04 16:25:49

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:25:49]
  • 评测
  • 测评结果:WA
  • 用时:45ms
  • 内存:47664kb
  • [2022-01-15 12:33:38]
  • 提交

answer

#include <bits/stdc++.h>
#define For(i,a,b) for(int i=a;i<=b;i++)
#define Rev(i,a,b) for(int i=a;i>=b;i--)
#define clr(a,v) memset(a,v,sizeof(a))
#define Freopen(file) \
freopen(file".in","r",stdin); \
freopen(file".out","w",stdout);
//#define int long long
using namespace std;

const int N=1e3+5;

char mp[N][N];
int n,m,r,c;
int num[N][N],ncnt;
vector<int> to[N*N];
int col[N*N];

void add(int x,int y)
{
	to[x].push_back(y);
	to[y].push_back(x);
}

void dfs(int u,int cv)
{
	col[u]=cv;
	
	for(auto v:to[u]){
		if(col[v]) continue;
		col[v]=3-cv;
		dfs(v,cv);
	}
}

signed main()
{
	cin>>n>>m>>r>>c;
	For(i,1,n) cin>>(mp[i]+1);
	
	int S=0,T=0;
	
	For(i,1,n){
		For(j,1,m){
			if(mp[i][j]!='@') num[i][j]=++ncnt;
			if(mp[i][j]=='A') S=ncnt;
			if(mp[i][j]=='B') T=ncnt;
		}
	}
	
	For(i,1,n){
		For(j,1,m){
			if(mp[i][j]!='@'){
				if(i+r<=n && j+c<=m && mp[i+r][j+c]!='@'){
					add(num[i][j],num[i+r][j+c]);
				}
				if(i+c<=n && j+r<=m && mp[i+c][j+r]!='@'){
					add(num[i][j],num[i+c][j+r]);
				}
			}
		}
	}
	
	if(to[S].empty()){
		puts("Bob");
		return 0;
	}
	
	dfs(S,1);
	
	if(col[T]==0){
		puts("Alice");
	}
	else{
		if(col[T]==col[S]){
			puts("Alice");
		}
		else{
			puts("Bob");
		}
	}
	
	return 0;
}

详细

Test #1:

score: 100
Accepted
time: 30ms
memory: 41680kb

Test #2:

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

Test #3:

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

Test #4:

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

Test #5:

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

Test #6:

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

Test #7:

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

Test #8:

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

Test #9:

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

Test #10:

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

Test #11:

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

Test #12:

score: -100
Wrong Answer
time: 45ms
memory: 42604kb