QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#55407#2213. KnightExplodingKonjacWA 119ms48612kbC++174.6kb2022-10-13 16:42:492022-10-13 16:42:51

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-10-13 16:42:51]
  • 评测
  • 测评结果:WA
  • 用时:119ms
  • 内存:48612kb
  • [2022-10-13 16:42:49]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
//#define OPENIOBUF

namespace FastIO
{
	class FastIOBase
	{
	protected:
#ifdef OPENIOBUF
		static const int BUFSIZE=1<<22;
		char buf[BUFSIZE+1];
		int buf_p=0;
#endif
		FILE *target;
	public:
#ifdef OPENIOBUF
		virtual void flush()=0;
#endif
		FastIOBase(FILE *f): target(f){}
		~FastIOBase()=default;
	};

	class FastOutput: public FastIOBase
	{
#ifdef OPENIOBUF
	public:
		inline void flush()
			{ fwrite(buf,1,buf_p,target),buf_p=0; }
#endif
	protected:
		inline void __putc(char x)
		{
#ifdef OPENIOBUF
			if(buf[buf_p++]=x,buf_p==BUFSIZE)flush();
#else
			putc(x,target);
#endif
		}
		template<typename T>
		inline void __write(T x)
		{
			static char stk[64],*top;top=stk;
			if(x<0) return __putc('-'),__write(-x);
			do *(top++)=x%10,x/=10; while(x);
			for(;top!=stk;__putc(*(--top)+'0'));
		}
	public:
		FastOutput(FILE *f=stdout): FastIOBase(f){}
#ifdef OPENIOBUF
		~FastOutput(){ flush(); }
#endif
		template<typename ...T>
		inline void writesp(const T &...x)
			{ initializer_list<int>{(this->operator<<(x),__putc(' '),0)...}; }
		template<typename ...T>
		inline void writeln(const T &...x)
			{ initializer_list<int>{(this->operator<<(x),__putc('\n'),0)...}; }
		inline FastOutput &operator <<(char x)
			{ return __putc(x),*this; }
		inline FastOutput &operator <<(const char *s)
			{ for(;*s;__putc(*(s++)));return *this; }
		inline FastOutput &operator <<(const string &s)
			{ return (*this)<<s.c_str(); }
		template<typename T,typename=typename enable_if<is_integral<T>::value>::type>
		inline FastOutput &operator <<(const T &x)
			{ return __write(x),*this; }
	}qout;

	class FastInput: public FastIOBase
	{
#ifdef OPENIOBUF
	public:
		inline void flush()
			{ buf[fread(buf,1,BUFSIZE,target)]='\0',buf_p=0; }
#endif
	protected:
		inline char __getc()
		{
#ifdef OPENIOBUF
			if(buf_p==BUFSIZE) flush();
			return buf[buf_p++];
#else
			return getc(target);
#endif
		}
	public:
#ifdef OPENIOBUF
		FastInput(FILE *f=stdin): FastIOBase(f){ buf_p=BUFSIZE; }
#else
		FastInput(FILE *f=stdin): FastIOBase(f){}
#endif
		inline char getchar() { return __getc(); }
		template<typename ...T>
		inline void read(T &...x)
			{ initializer_list<int>{(this->operator>>(x),0)...}; }
		inline FastInput &operator >>(char &x)
			{ while(isspace(x=__getc()));return *this; }
		template<typename T,typename=typename enable_if<is_integral<T>::value>::type>
		inline FastInput &operator >>(T &x)
		{
			static char ch,sym;x=sym=0;
			while(isspace(ch=__getc()));
			if(ch=='-') sym=1,ch=__getc();
			for(;isdigit(ch);x=(x<<1)+(x<<3)+(ch^48),ch=__getc());
			return sym?x=-x:x,*this;
		}
		inline FastInput &operator >>(char *s)
		{
			while(isspace(*s=__getc()));
			for(;!isspace(*s) && *s && ~*s;*(++s)=__getc());
			return *s='\0',*this;
		}
		inline FastInput &operator >>(string &s)
		{
			char str_buf[(1<<8)+1],*p=str_buf;
			char *const buf_end=str_buf+(1<<8);
			while(isspace(*p=__getc()));
			for(s.clear(),p++;;p=str_buf)
			{
				for(;p!=buf_end && !isspace(*p=__getc()) && *p && ~*p;p++);
				*p='\0',s.append(str_buf);
				if(p!=buf_end) break;
			}
			return *this;
		}
	}qin;
}
using namespace FastIO;

typedef long long LL;
typedef long double LD;
typedef unsigned int UI;
typedef unsigned long long ULL;

#ifndef DADALZY
#define FILEIO(file) freopen(file".in","r",stdin),freopen(file".out","w",stdout)
#else
#define FILEIO(file)
#endif

int n,m,r,c;
char s[1005][1005];
constexpr int dirs[][2]={{1,1},{1,-1},{-1,1},{-1,-1}};
inline int getId(int i,int j) { return (i-1)*n+j; }
vector<int> g[1000005];
int tot,id[1000005],col[1000005];
void dfs(int u,int now)
{
	id[u]=tot,col[u]=now;
	for(auto &v: g[u])
		if(!id[v]) dfs(v,3-now);
}
int main()
{
	qin>>n>>m>>r>>c;
	for(int i=1;i<=n;i++) qin>>(s[i]+1);
	if(!r && !c) return qout<<"Bob",0;
	int posa=0,posb=0;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
		{
			if(s[i][j]=='A') posa=getId(i,j);
			if(s[i][j]=='B') posb=getId(i,j);
			if(s[i][j]=='@') continue;
			for(auto &[dx,dy]: dirs)
			{
				int x=i+dx*r,y=j+dy*c;
				if(x<1 || y<1 || x>n || y>m) continue;
				if(s[x][y]=='@') continue;
				g[getId(i,j)].push_back(getId(x,y));
			}
			for(auto &[dx,dy]: dirs)
			{
				int x=i+dx*c,y=j+dy*r;
				if(x<1 || y<1 || x>n || y>m) continue;
				if(s[x][y]=='@') continue;
				g[getId(i,j)].push_back(getId(x,y));
			}
		}
	for(int i=1;i<=n*m;i++) if(!id[i]) tot++,dfs(i,1);
	bool fl=true;
	for(auto &v: g[posa]) if(v!=posb) fl=false;
	if(fl) return qout<<"Bob",0;
	qout<<((id[posa]!=id[posb] || col[posa]!=col[posb])?"Alice":"Bob");
	return 0;
}

Details

Test #1:

score: 100
Accepted
time: 85ms
memory: 43268kb

Test #2:

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

Test #3:

score: 0
Accepted
time: 119ms
memory: 48612kb

Test #4:

score: -100
Wrong Answer
time: 77ms
memory: 40168kb