QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#228020#7635. Fairy Chessucup-team1209#WA 1ms3836kbC++201.6kb2023-10-28 10:42:162023-10-28 10:42:17

Judging History

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

  • [2023-10-28 10:42:17]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3836kb
  • [2023-10-28 10:42:16]
  • 提交

answer

#include<bits/stdc++.h>
using std::cin, std::cout;
int n, m;
using u64 = unsigned long long;
std::unordered_map<u64, int> map[15];
u64 atk[256][64];
int id(int x, int y) { return x * 8 + y; }
char c[100];
u64 sid(int x, int y) {
	if(x < 0 || x >= 8) return 0;
	if(y < 0 || y >= 8) return 0;
	return 1ull << id(x, y);
}
bool dfs(u64 s, int id) {
	if(s == 0 || id == 12) {
		return 0;
	}
	auto iter = map[id].find(s);
	if(iter != map[id].end()) return iter -> second;
	int & ans = map[id][s];
	for(u64 x = s;x;x &= x - 1) {
		int p = __builtin_ctzll(x);
		if(~s & atk[c[id]][p]) {
			continue;
		}
		ans = ans || !dfs(s & ~atk[c[id]][p], id + 1);
	}
	return ans;
}
int main() {
	std::ios::sync_with_stdio(false), cin.tie(0);
	for(int i = 0;i < 8;++i) {
		for(int j = 0;j < 8;++j) {
			for(int k = 0;k < 8;++k) {
				atk['R'][id(i, j)] |= 1ull << id(i, k);
				atk['R'][id(i, j)] |= 1ull << id(k, j);
				atk['B'][id(i, j)] |= sid(i + k, j + k);
				atk['B'][id(i, j)] |= sid(i + k, j - k);
				atk['B'][id(i, j)] |= sid(i - k, j + k);
				atk['B'][id(i, j)] |= sid(i - k, j - k);
			}
			atk['K'][id(i, j)] |= sid(i, j);
			for(int u : {2, -2})
				for(int v : {1, -1}) {
					atk['K'][id(i, j)] |= sid(i + u, j + v);
					atk['K'][id(i, j)] |= sid(i + v, j + u);
				}
			atk['Q'][id(i, j)] = atk['R'][id(i, j)] | atk['B'][id(i, j)];
			atk['A'][id(i, j)] = atk['B'][id(i, j)] | atk['K'][id(i, j)];
			atk['C'][id(i, j)] = atk['R'][id(i, j)] | atk['K'][id(i, j)];
			atk['M'][id(i, j)] = atk['Q'][id(i, j)] | atk['K'][id(i, j)];
		}
	}
	cin >> c;
	cout << (dfs(-1ull, 0) ? "Alice" : "Bob") << '\n';
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3644kb

input:

BBAARRCCQQMM

output:

Bob

result:

ok single line: 'Bob'

Test #2:

score: 0
Accepted
time: 0ms
memory: 3616kb

input:

BAMBAMQQRCCR

output:

Alice

result:

ok single line: 'Alice'

Test #3:

score: 0
Accepted
time: 0ms
memory: 3608kb

input:

QQRAACMRMCBB

output:

Alice

result:

ok single line: 'Alice'

Test #4:

score: 0
Accepted
time: 0ms
memory: 3544kb

input:

MBBARQRMACQC

output:

Alice

result:

ok single line: 'Alice'

Test #5:

score: 0
Accepted
time: 0ms
memory: 3576kb

input:

ACQCMQRBBRMA

output:

Alice

result:

ok single line: 'Alice'

Test #6:

score: 0
Accepted
time: 0ms
memory: 3572kb

input:

MRCMABRQCQAB

output:

Alice

result:

ok single line: 'Alice'

Test #7:

score: -100
Wrong Answer
time: 0ms
memory: 3836kb

input:

BBRCMMQAAQRC

output:

Bob

result:

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