QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#235057#7635. Fairy Chessucup-team870#WA 128ms3640kbC++141.7kb2023-11-02 12:04:462023-11-02 12:04:46

Judging History

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

  • [2023-11-02 12:04:46]
  • 评测
  • 测评结果:WA
  • 用时:128ms
  • 内存:3640kb
  • [2023-11-02 12:04:46]
  • 提交

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) {
    vis[x][y] += k;
    cnt[0][x] += k;
    cnt[1][y] += k;
    cnt[2][x-y+8] += k;
    cnt[3][x+y] += 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);
                    int flag = dfs(c+1);
                    place(i, j, -1);
                    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: 128ms
memory: 3640kb

input:

BBAARRCCQQMM

output:

Bob

result:

ok single line: 'Bob'

Test #2:

score: 0
Accepted
time: 13ms
memory: 3508kb

input:

BAMBAMQQRCCR

output:

Alice

result:

ok single line: 'Alice'

Test #3:

score: -100
Wrong Answer
time: 27ms
memory: 3388kb

input:

QQRAACMRMCBB

output:

Bob

result:

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