Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- 시뮬레이션
- Trie
- Linked list
- 코테
- boj
- SQL
- django
- CSV
- programmers
- Priority Queue
- aws
- gpdb
- BFS
- SWEA
- 코딩테스트
- Vue.js
- hash table
- DFS
- 모의SW역량테스트
- Python
- JavaScript
- Bruth Force
- GitHub
- 알고리즘
- 구현
- spring boot
- Data Structure
- Back tracking
- Algorithm
- 알고리듬
Archives
- Today
- Total
hotamul의 개발 이야기
[Algorithm][C++] BOJ 17825 주사위 윷놀이 본문
myt-algorithm-practice/Samsung SW Certi Adv
[Algorithm][C++] BOJ 17825 주사위 윷놀이
hotamul 2021. 10. 14. 23:45na982님 풀이 참고
[삼성 SW 역량 테스트] 주사위 윷놀이
#include const int board[33][6] = { {0,1,2,3,4,5}, {2,2,3,4,5,6}, {4,3,4,5,6,7}, {6,4,5,6,7,8}, {8,5,6,7,8,9}, {10,21,22,23,24,25}, {12,7,8,9,10,11}, {14,8,9,10,11,12}, {16,9,10,11,12,13}, {18,10,11..
na982.tistory.com
코드
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
const int board[33][6] = {
{0,1,2,3,4,5},
{2,2,3,4,5,6},
{4,3,4,5,6,7},
{6,4,5,6,7,8},
{8,5,6,7,8,9},
{10,21,22,23,24,25},
{12,7,8,9,10,11},
{14,8,9,10,11,12},
{16,9,10,11,12,13},
{18,10,11,12,13,14},
{20,27,28,24,25,26},
{22,12,13,14,15,16},
{24,13,14,15,16,17},
{26,14,15,16,17,18},
{28,15,16,17,18,19},
{30,29,30,31,24,25},
{32,17,18,19,20,32},
{34,18,19,20,32,32},
{36,19,20,32,32,32},
{38,20,32,32,32,32},
{40,32,32,32,32,32},
{13,22,23,24,25,26},
{16,23,24,25,26,20},
{19,24,25,26,20,32},
{25,25,26,20,32,32},
{30,26,20,32,32,32},
{35,20,32,32,32,32},
{22,28,24,25,26,20},
{24,24,25,26,20,32},
{28,30,31,24,25,26},
{27,31,24,25,26,20},
{26,24,25,26,20,32},
{0,32,32,32,32,32}
};
int turn[10];
int get_score(int state) {
int ret = 0;
bool visited[33] = { 0, };
int pos[4] = { 0, };
for (int round = 0; round < 10; round++) {
int move = turn[round];
int horse = (state >> (round * 2)) & 3;
int& cur_pos = pos[horse];
int next_pos = board[cur_pos][move];
if (visited[next_pos] && next_pos != 32) return -1;
ret += board[next_pos][0];
visited[cur_pos] = false;
visited[next_pos] = true;
cur_pos = next_pos;
}
return ret;
}
int main() {
for (int i = 0; i < 10; i++) {
scanf("%d", &turn[i]);
}
int ret = 0;
for (int state = 0; state < (1 << 20); state++) {
int candi = get_score(state);
if (candi > ret) ret = candi;
}
printf("%d", ret);
return 0;
}
'myt-algorithm-practice > Samsung SW Certi Adv' 카테고리의 다른 글
[Algorithm][C++] BOJ 15686 치킨 배달 (0) | 2021.10.16 |
---|---|
[Algorithm][C++] BOJ 19237 어른 상어 (0) | 2021.10.15 |
[Algorithm][C++] BOJ 19236 청소년 상어 (0) | 2021.10.04 |
[Algorithm][C++] BOJ 20055 컨베이어 벨트 위의 로봇 (0) | 2021.10.02 |
[Algorithm][C++] BOJ 17837 새로운 게임 2 (0) | 2021.09.30 |
Comments