QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#235063 | #7635. Fairy Chess | ucup-team870# | WA | 1ms | 3684kb | C++14 | 2.7kb | 2023-11-02 12:25:28 | 2023-11-02 12:25:29 |
Judging History
answer
#include <bits/stdc++.h>
#define rep(i,l,r) for(int i=l; i<=r; i++)
#define per(i,r,l) for(int i=r; i>=l; i--)
#define IOS {cin.tie(0);cout.tie(0);ios::sync_with_stdio(0);}
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int N = 10;
char s[100];
int vis[N][N];
int cnt[4][N*2];
int dx[] = {-2, -1, 1, 2, 2, 1, -1, -2};
int dy[] = {1, 2, 2, 1, -1, -2, -2, -1};
bool check(int x, int y, char c) {
if (c == 'B' || c == 'A') {
if (cnt[2][x-y+8] || cnt[3][x+y]) return true;
}
if (c == 'R' || c == 'C') {
if (cnt[0][x] || cnt[1][y]) return true;
}
if (c == 'Q' || c == 'M') {
if (cnt[2][x-y+8] || cnt[3][x+y] || cnt[0][x] || cnt[1][y]) return true;
}
if (c == 'A' || c == 'C' || c == 'M') {
rep (k, 0, 7) {
int tx = x + dx[k], ty = y + dy[k];
if (tx >= 1 && tx <= 8 && ty >= 1 && ty <= 8) {
if (vis[tx][ty]) return true;
}
}
}
return false;
}
void place(int x, int y, int k, char c) {
// vis[x][y] += k;
cnt[0][x] += k;
cnt[1][y] += k;
cnt[2][x-y+8] += k;
cnt[3][x+y] += k;
if (c == 'B' || c == 'A') {
rep (i, -8, 8) {
int tx = x+i, ty = y+i;
if (tx>=1&&tx<=8&&ty>=1&&ty<=8) vis[tx][ty]+=k;
tx = x+i, ty = y-i;
if (tx>=1&&tx<=8&&ty>=1&&ty<=8) vis[tx][ty]+=k;
}
}
if (c == 'R' || c == 'C') {
rep (i, 1, 8) vis[x][i] += k, vis[i][y] += k;
}
if (c == 'Q' || c == 'M') {
rep (i, 1, 8) {
vis[x][i] += k, vis[i][y] += k;
}
rep (i, -8, 8) {
int tx = x+i, ty = y+i;
if (tx>=1&&tx<=8&&ty>=1&&ty<=8) vis[tx][ty]+=k;
tx = x+i, ty = y-i;
if (tx>=1&&tx<=8&&ty>=1&&ty<=8) vis[tx][ty]+=k;
}
}
if (c == 'A' || c == 'C' || c == 'M') {
rep (k, 0, 7) {
int tx = x + dx[k], ty = y + dy[k];
if (tx >= 1 && tx <= 8 && ty >= 1 && ty <= 8) {
vis[tx][ty] += k;
}
}
}
}
bool dfs(int c) {
// cout <<c;
if (c == 13) return false;
int xx = 8;
if (c == 1) xx = 4;
rep (i, 1, xx) {
rep (j, 1, xx) {
if (!vis[i][j]) {
if (!check(i, j, s[c])) {
place(i, j, 1, s[c]);
int flag = dfs(c+1);
place(i, j, -1, s[c]);
if (flag == 0) return true;
}
}
}
}
return false;
}
int main() {
scanf("%s", s+1);
if (dfs(1)) puts("Alice");
else puts("Bob");
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3324kb
input:
BBAARRCCQQMM
output:
Bob
result:
ok single line: 'Bob'
Test #2:
score: 0
Accepted
time: 1ms
memory: 3512kb
input:
BAMBAMQQRCCR
output:
Alice
result:
ok single line: 'Alice'
Test #3:
score: 0
Accepted
time: 1ms
memory: 3684kb
input:
QQRAACMRMCBB
output:
Alice
result:
ok single line: 'Alice'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3672kb
input:
MBBARQRMACQC
output:
Alice
result:
ok single line: 'Alice'
Test #5:
score: 0
Accepted
time: 0ms
memory: 3324kb
input:
ACQCMQRBBRMA
output:
Alice
result:
ok single line: 'Alice'
Test #6:
score: -100
Wrong Answer
time: 0ms
memory: 3472kb
input:
MRCMABRQCQAB
output:
Bob
result:
wrong answer 1st lines differ - expected: 'Alice', found: 'Bob'