Posts 17825 Samsung sw test
Post
Cancel

17825 Samsung sw test

17825 Samsung sw test

코드

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#include <iostream>
#include <vector>
using namespace std;

typedef struct Map {
	int score;
	int next;
	int blueNext;
} Map;

int dice[10];
Map map[33] = { {0, 1, -1},{2, 2, -1}, {4, 3, -1}, {6,4 , -1}, {8, 5, -1},
				{10, 6, 21}, {12, 7, -1}, {14, 8, -1}, {16, 9, -1}, {18, 10, -1},
				{20, 11, 24 }, { 22, 12, -1 }, { 24, 13, -1 }, { 26, 14, -1 }, { 28, 15, -1 },
				{30, 16, 26}, {32, 17, -1}, {34, 18, -1}, {36, 19, -1}, {38, 20, -1},
				{40, 32, -1}, {13, 22, -1}, {16, 23, -1}, {19, 29, -1}, {22, 25, -1},
				{24, 29, -1}, {28, 27, -1}, {27, 28, -1}, {26, 29, -1}, {25, 30, -1},
				{30, 31, -1}, {35, 20, -1}, {0, -1, -1} };

int getScore(int piece[4], int score, int deep);

int main() {
	for (int i = 0; i < 10; i++)
		cin >> dice[i];

	int temp[4] = { 0,0,0,0 };
	cout << getScore(temp, 0, 0);

}

int getScore(int piece[4], int score, int deep) {
	if (deep == 10)
		return score;
	int maxScore = 0;
	for (int i = 0; i < 4; i++) {
		int current = piece[i];
		if (current >= 32)
			continue;
		int next = map[current].blueNext != -1 ? map[current].blueNext : map[current].next;
		for (int j = 0; j < dice[deep]; j++) {
			current = next;
			if (current == 32)
				break;
			next = map[current].next;
		}

		int temp[4];
		for (int j = 0; j < 4; j++) {
			if (i != j)
				temp[j] = piece[j];
			else
				temp[j] = current;
		}

		if (current == 32) {
			int a = getScore(temp, score, deep + 1);
			maxScore = a > maxScore ? a : maxScore;
			continue;
		}

		bool check = false;
		for (int j = 0; j < 4; j++) {
			if (piece[j] == current)
				check = true;
		}
		if (!check) {
			int a = getScore(temp, score + map[current].score, deep + 1);
			maxScore = a > maxScore ? a : maxScore;
		}
	}

	return maxScore;
}
This post is licensed under CC BY 4.0 by the author.

17822 Samsung sw test

1799 bishop

Comments powered by Disqus.