QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#229227#7635. Fairy Chessucup-team052#WA 53ms3944kbC++141.8kb2023-10-28 15:30:342023-10-28 15:30:34

Judging History

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

  • [2023-10-28 15:30:34]
  • 评测
  • 测评结果:WA
  • 用时:53ms
  • 内存:3944kb
  • [2023-10-28 15:30:34]
  • 提交

answer

#include<bits/stdc++.h>
#ifdef xay5421
#define D(...) fprintf(stderr,__VA_ARGS__)
#define DD(...) D(#__VA_ARGS__ "="),debug_helper::debug(__VA_ARGS__),D("\n")
#include"/home/xay5421/debug.hpp"
#else
#define D(...) ((void)0)
#define DD(...) ((void)0)
#endif
#define pb push_back
#define eb emplace_back
#define SZ(x) ((int)(x).size())
#define each(x,v) for(auto&x:v)
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define per(i,a,b) for(int i=(a);i>=(b);--i)
template<class T>void rd(T&x){int f=0,c;while(!isdigit(c=getchar()))f^=!(c^45);x=(c&15);while(isdigit(c=getchar()))x=x*10+(c&15);if(f)x=-x;}
template<class T>void pt(T x,int c=-1){if(x<0)putchar('-'),x=-x;if(x>9)pt(x/10);putchar(x%10+48);if(c!=-1)putchar(c);}
using namespace std;
using LL=long long;
using ULL=unsigned long long;
const int N=8;
const char ST[]="BRQACM";
char s[15];
int a[15];
ULL st[6][N*N];
int zip(int x,int y){return x*8+y;}
int ID(char c){
	rep(i,0,5)if(ST[i]==c)return i;
	assert(0);
}
int dfs(int u,ULL mp,ULL mp1){
	// DD(u,mp);
	if(u>=12){
		return 0;
	}
	if(__builtin_popcountll(mp)==64)return 0;
	rep(i,0,63)if((~mp>>i&1)&&(st[a[u]][i]&mp1)==0){
		if(!dfs(u+1,mp|st[a[u]][i],mp1|(1ULL<<i)))return 1;
	}
	return 0;
}
int main(){
	rep(i,0,7){
		rep(j,0,7){
			ULL knight=0;
			rep(ii,0,7){
				rep(jj,0,7){
					st[0][zip(i,j)]|=ULL(i+j==ii+jj||i-j==ii-jj)<<zip(ii,jj);
					st[1][zip(i,j)]|=ULL(i==ii|j==jj)<<zip(ii,jj);
					auto tmp=minmax(abs(i-ii),abs(j-jj));
					if(tmp.first==1&&tmp.second==2){
						knight|=1ULL<<zip(ii,jj);
					}
				}
			}
			st[2][zip(i,j)]=st[0][zip(i,j)]|st[1][zip(i,j)];
			st[3][zip(i,j)]=st[0][zip(i,j)]|knight;
			st[4][zip(i,j)]=st[1][zip(i,j)]|knight;
			st[5][zip(i,j)]=st[2][zip(i,j)]|knight;
		}
	}
	scanf("%s",s);
	rep(i,0,11){
		a[i]=ID(s[i]);
	}
	puts(dfs(0,0,0)?"Alice":"Bob");
	return 0;
}

详细

Test #1:

score: 100
Accepted
time: 53ms
memory: 3944kb

input:

BBAARRCCQQMM

output:

Bob

result:

ok single line: 'Bob'

Test #2:

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

input:

BAMBAMQQRCCR

output:

Alice

result:

ok single line: 'Alice'

Test #3:

score: -100
Wrong Answer
time: 30ms
memory: 3896kb

input:

QQRAACMRMCBB

output:

Bob

result:

wrong answer 1st lines differ - expected: 'Alice', found: 'Bob'