QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#563107#4315. 简单的卡牌游戏ElegiaAC ✓194ms69396kbC++232.7kb2024-09-14 02:46:422024-09-14 02:46:43

Judging History

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

  • [2024-09-14 02:46:43]
  • 评测
  • 测评结果:AC
  • 用时:194ms
  • 内存:69396kb
  • [2024-09-14 02:46:42]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

int mem[8][8][8][8][8][8][8][8];

vector<int> S[2],H[2],C[2],D[2];

void take_complement(vector<int> &a,vector<int> &b)
{
	for (int i = 1;i <= 13;i++)
	{
		bool ok = 0;
		for (int j = 0;j < a.size();j++)
			if (a[j] == i)
				ok = 1;
		if (!ok)
			b.push_back(i);
	}
}

int dfs(int l,bool cur,int sl,int sr,int hl,int hr,int cl,int cr,int dl,int dr)
{
	if (l == 52)
		return 0;
	int &res = mem[sl][sr][hl][hr][cl][cr][dl][dr];
	if (res != 1e9)
		return res;
	int MIN = 1;
	for (int i = 0;i < S[cur].size();i++)
	{
		int val = S[cur][i];
		if (val == 7 - sl)
			MIN = min(MIN,dfs(l + 1,cur ^ 1,sl + 1,max(sr,1),hl,hr,cl,cr,dl,dr));
		if (val == 7 + sr)
			MIN = min(MIN,dfs(l + 1,cur ^ 1,max(sl,1),sr + 1,hl,hr,cl,cr,dl,dr));
	}
	for (int i = 0;i < H[cur].size();i++)
	{
		int val = H[cur][i];
		if (val == 7 - hl)
			MIN = min(MIN,dfs(l + 1,cur ^ 1,sl,sr,hl + 1,max(hr,1),cl,cr,dl,dr));
		if (val == 7 + hr)
			MIN = min(MIN,dfs(l + 1,cur ^ 1,sl,sr,max(hl,1),hr + 1,cl,cr,dl,dr));
	}
	for (int i = 0;i < C[cur].size();i++)
	{
		int val = C[cur][i];
		if (val == 7 - cl)
			MIN = min(MIN,dfs(l + 1,cur ^ 1,sl,sr,hl,hr,cl + 1,max(cr,1),dl,dr));
		if (val == 7 + cr)
			MIN = min(MIN,dfs(l + 1,cur ^ 1,sl,sr,hl,hr,max(cl,1),cr + 1,dl,dr));
	}
	for (int i = 0;i < D[cur].size();i++)
	{
		int val = D[cur][i];
		if (val == 7 - dl)
			MIN = min(MIN,dfs(l + 1,cur ^ 1,sl,sr,hl,hr,cl,cr,dl + 1,max(dr,1)));
		if (val == 7 + dr)
			MIN = min(MIN,dfs(l + 1,cur ^ 1,sl,sr,hl,hr,cl,cr,max(dl,1),dr + 1));
	}
	return res = -MIN;
}

int main()
{
	string s;
	while (cin >> s)
	{
		int v = 0;
		for (int i = 1;i < s.size();i++)
			v = v * 10 + s[i] - '0';
		if (s[0] == 'S')
			S[0].push_back(v);
		if (s[0] == 'H')
			H[0].push_back(v);
		if (s[0] == 'C')
			C[0].push_back(v);
		if (s[0] == 'D')
			D[0].push_back(v);
	}
	take_complement(S[0],S[1]);
	take_complement(H[0],H[1]);
	take_complement(C[0],C[1]);
	take_complement(D[0],D[1]);
	bool ok = 0;
	for (int i = 0;i < S[0].size();i++)
		if (S[0][i] == 7)
			ok = 1;
	for (int a1 = 0;a1 <= 7;a1++)
	for (int a2 = 0;a2 <= 7;a2++)
	for (int a3 = 0;a3 <= 7;a3++)
	for (int a4 = 0;a4 <= 7;a4++)
	for (int a5 = 0;a5 <= 7;a5++)
	for (int a6 = 0;a6 <= 7;a6++)
	for (int a7 = 0;a7 <= 7;a7++)
	for (int a8 = 0;a8 <= 7;a8++)
	mem[a1][a2][a3][a4][a5][a6][a7][a8] = 1e9;
	if (ok)
	{
		int res = dfs(1,1,1,1,0,0,0,0,0,0);
		if (res == 1)
			puts("Bob");
		if (res == 0)
			puts("Draw");
		if (res == -1)
			puts("Alice");
	}
	else
	{
		int res = dfs(1,0,1,1,0,0,0,0,0,0);
		if (res == 1)
			puts("Alice");
		if (res == 0)
			puts("Draw");
		if (res == -1)
			puts("Bob");
	}
	return 0;
}

详细

Test #1:

score: 100
Accepted
time: 120ms
memory: 69084kb

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: 101ms
memory: 69152kb

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: 99ms
memory: 69380kb

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: 101ms
memory: 69396kb

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: 130ms
memory: 69096kb

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: 59ms
memory: 69152kb

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: 63ms
memory: 69076kb

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: 59ms
memory: 69388kb

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: 194ms
memory: 69120kb

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'