QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#17927 | #2213. Knight | CharlieVinnie# | WA | 45ms | 44824kb | C++14 | 1.3kb | 2022-01-15 12:32:10 | 2022-05-04 16:25:46 |
Judging History
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];
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;
}
Details
Test #1:
score: 100
Accepted
time: 31ms
memory: 41132kb
Test #2:
score: 0
Accepted
time: 5ms
memory: 32120kb
Test #3:
score: -100
Wrong Answer
time: 45ms
memory: 44824kb