QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#291061#4315. 简单的卡牌游戏MoRanSkyAC ✓95ms134876kbC++233.5kb2023-12-26 04:40:502023-12-26 04:40:51

Judging History

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

  • [2023-12-26 04:40:51]
  • 评测
  • 测评结果:AC
  • 用时:95ms
  • 内存:134876kb
  • [2023-12-26 04:40:50]
  • 提交

answer

// Skyqwq
#include <bits/stdc++.h>

#define pb push_back
#define fi first
#define se second
#define mp make_pair

using namespace std;

typedef pair<int, int> PII;
typedef long long LL;

template <typename T> bool chkMax(T &x, T y) { return (y > x) ? x = y, 1 : 0; }
template <typename T> bool chkMin(T &x, T y) { return (y < x) ? x = y, 1 : 0; }

template <typename T> void inline read(T &x) {
    int f = 1; x = 0; char s = getchar();
    while (s < '0' || s > '9') { if (s == '-') f = -1; s = getchar(); }
    while (s <= '9' && s >= '0') x = x * 10 + (s ^ 48), s = getchar();
    x *= f;
}

char op[10];

int fl[4][14];

int f[8][8][8][8][8][8][8][8][2];

int inline get(char c) {
	if (c == 'S') return 0;
	if (c == 'H') return 1;
	if (c == 'C') return 2;
	return 3;
}

int dp(int A, int B, int C, int D, int E, int F, int G, int H, int o) {
	if (A == 7 && B == 7 && C == 7 && D == 7 && E == 7 && F == 7  && G == 7  && H == 7) return 2;
	if (~f[A][B][C][D][E][F][G][H][o]) return f[A][B][C][D][E][F][G][H][o];
	int &v = f[A][B][C][D][E][F][G][H][o];
	bool o1 = 0, o2 = 0;

	if (!A) {
		if (fl[0][7] == o) {
			int w = dp(A + 1, B + 1, C, D, E, F, G, H, o ^ 1);
			if (w == 0) o1 = 1;
			else if (w == 2) o2 = 1;
		}
	} else {
		if (A < 7 && fl[0][7 - A] == o) {
			int w = dp(A + 1, B, C, D, E, F, G, H, o ^ 1);
			if (w == 0) o1 = 1;
			else if (w == 2) o2 = 1;
		}
		if (B < 7 && fl[0][7 + B] == o) {
			int w = dp(A, B + 1, C, D, E, F, G, H, o ^ 1);
			if (w == 0) o1 = 1;
			else if (w == 2) o2 = 1;
		}
	}

	if (!C) {
		if (fl[1][7] == o) {
			int w = dp(A, B, C + 1, D + 1, E, F, G, H, o ^ 1);
			if (w == 0) o1 = 1;
			else if (w == 2) o2 = 1;
		}
	} else {
		if (C < 7 && fl[1][7 - C] == o) {
			int w = dp(A, B, C + 1, D, E, F, G, H, o ^ 1);
			if (w == 0) o1 = 1;
			else if (w == 2) o2 = 1;
		}
		if (D < 7 && fl[1][7 + D] == o) {
			int w = dp(A, B, C, D + 1, E, F, G, H, o ^ 1);
			if (w == 0) o1 = 1;
			else if (w == 2) o2 = 1;
		}
	}

	if (!E) {
		if (fl[2][7] == o) {
			int w = dp(A, B, C, D, E + 1, F + 1, G, H, o ^ 1);
			if (w == 0) o1 = 1;
			else if (w == 2) o2 = 1;
		}
	} else {
		if (E < 7 && fl[2][7 - E] == o) {
			int w = dp(A, B, C, D, E + 1, F, G, H, o ^ 1);
			if (w == 0) o1 = 1;
			else if (w == 2) o2 = 1;
		}
		if (F < 7 && fl[2][7 + F] == o) {
			int w = dp(A, B, C, D, E, F + 1, G, H, o ^ 1);
			if (w == 0) o1 = 1;
			else if (w == 2) o2 = 1;
		}
	}

	if (!G) {
		if (fl[3][7] == o) {
			int w = dp(A, B, C, D, E, F, G + 1, H + 1, o ^ 1);
			if (w == 0) o1 = 1;
			else if (w == 2) o2 = 1;
		}
	} else {
		if (G < 7 && fl[3][7 - G] == o) {
			int w = dp(A, B, C, D, E, F, G + 1, H, o ^ 1);
			if (w == 0) o1 = 1;
			else if (w == 2) o2 = 1;
		}
		if (H < 7 && fl[3][7 + H] == o) {
			int w = dp(A, B, C, D, E, F, G, H + 1, o ^ 1);
			if (w == 0) o1 = 1;
			else if (w == 2) o2 = 1;
		}
	}

	if (o1) v = 1;
	else if (o2) v = 2;
	else v = 0;
	return v;
}

int main() {
	memset(f, -1, sizeof f);
	int s = 1;
	for (int i = 0; i < 4; i++) 
    	for (int j = 1; j <= 13; j++) 
    		fl[i][j] = 1;
    for (int i = 1; i <= 26; i++) {
    	scanf("%s", op);
    	int x = 0;
    	for (int j = 1; op[j]; j++) x = x * 10 + (op[j] ^ 48);
    	fl[get(op[0])][x] = 0;
    	if (get(op[0]) == 0 && x == 7) s = 0;
    }
    s ^= 1;
    int o = dp(1, 1, 0, 0, 0, 0, 0, 0, s);
    if (s == 1) {
    	if (o <= 1) o ^= 1;
    }
    if (o == 2) puts("Draw");
    else if (o == 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: 77ms
memory: 134824kb

input:

C12 S1 C7 H7 C3 D12 S5 C9 H4 S6 D10 H2 H1 S13 S10 C6 C10 H6 S7 D2 H3 D9 C13 D6 D4 H10

output:

Bob

result:

ok single line: 'Bob'

Test #2:

score: 0
Accepted
time: 60ms
memory: 134692kb

input:

C13 C7 C12 D11 D6 C2 D10 H1 H12 H2 S9 S10 D7 C3 H6 C6 S5 C5 D4 H4 C1 C4 D3 C8 D8 H13

output:

Alice

result:

ok single line: 'Alice'

Test #3:

score: 0
Accepted
time: 68ms
memory: 134772kb

input:

C5 H9 S12 D6 S10 C2 D11 S11 H5 C6 C12 C9 S4 D3 S7 S9 H1 H2 C3 S6 D1 S5 D2 H3 D12 C1

output:

Bob

result:

ok single line: 'Bob'

Test #4:

score: 0
Accepted
time: 65ms
memory: 134772kb

input:

D1 H9 H5 S4 D13 S8 H12 S5 D9 D5 C10 C8 D4 S12 S13 C4 H10 D6 H11 H8 C12 H2 S2 S6 H1 H13

output:

Bob

result:

ok single line: 'Bob'

Test #5:

score: 0
Accepted
time: 78ms
memory: 134828kb

input:

H2 D2 C9 H4 H10 C1 D1 D8 H7 C10 C3 S3 D10 S13 D6 C13 D5 C6 S8 H11 H3 H9 S4 S6 D13 H6

output:

Alice

result:

ok single line: 'Alice'

Test #6:

score: 0
Accepted
time: 52ms
memory: 134876kb

input:

C1 C2 C3 C4 C5 C6 C7 C8 C9 C10 C11 C12 C13 D1 D2 D3 D4 D5 D6 D7 D8 D9 D10 D11 D12 D13

output:

Draw

result:

ok single line: 'Draw'

Test #7:

score: 0
Accepted
time: 48ms
memory: 134736kb

input:

S1 S2 S3 S4 S5 S6 S7 S8 S9 S10 S11 S12 S13 H1 H2 H3 H4 H5 H6 H7 D1 D2 D3 D4 D5 D6


output:

Draw

result:

ok single line: 'Draw'

Test #8:

score: 0
Accepted
time: 45ms
memory: 134808kb

input:

S1 S2 S3 S4 S5 S6 S7 S8 S9 S10 S11 S12 S13 C1 C2 C3 C4 C5 C6 C7 C8 C9 C10 C11 C12 D12

output:

Draw

result:

ok single line: 'Draw'

Test #9:

score: 0
Accepted
time: 95ms
memory: 134828kb

input:

S2 S4 S6 S8 S10 S12 H1 H3 H5 H7 H9 H11 H13 C1 C3 C5 C7 C9 C11 C13 D2 D4 D6 D8 D10 D12

output:

Alice

result:

ok single line: 'Alice'