QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#235062#7635. Fairy Chessucup-team870#WA 1ms3560kbC++142.7kb2023-11-02 12:21:062023-11-02 12:21:07

Judging History

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

  • [2023-11-02 12:21:07]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3560kb
  • [2023-11-02 12:21:06]
  • 提交

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;
            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;
}

詳細信息

Test #1:

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

input:

BBAARRCCQQMM

output:

Bob

result:

ok single line: 'Bob'

Test #2:

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

input:

BAMBAMQQRCCR

output:

Alice

result:

ok single line: 'Alice'

Test #3:

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

input:

QQRAACMRMCBB

output:

Alice

result:

ok single line: 'Alice'

Test #4:

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

input:

MBBARQRMACQC

output:

Alice

result:

ok single line: 'Alice'

Test #5:

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

input:

ACQCMQRBBRMA

output:

Alice

result:

ok single line: 'Alice'

Test #6:

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

input:

MRCMABRQCQAB

output:

Bob

result:

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