👨‍💻
Hamin TIL
  • Today I Learned 🧑🏻‍💻
  • 회고
  • git
    • git_basics
      • Git 101
      • Git branch
      • Git_ignore
    • Git Book
    • 우아한형제들
    • pull_request
  • db
    • DA
      • 데이터표준화
      • 데이터_요건분석
      • 전사아키텍처_이해
      • 데이터모델링
    • SQL
      • SQL기본및활용
        • SQL활용
          • 절차형SQL
          • 계층형질의와셀프조인
          • DCL
          • 그룹함수
          • 윈도우함수
          • 표준조인
          • 집합연산자
          • 서브쿼리
        • SQL고급활용및튜닝
          • 옵티마이저와실행계획
          • 조인수행원리
          • 인덱스기본
        • SQL기본
          • 함수
          • 관계형데이터베이스개요
          • GROUPBY,HAVING절
          • DDL
          • 조인
          • ORDERBY절
          • DML
          • WHERE절
          • TCL
      • 데이터모델링의이해
        • 데이터모델과성능
          • 정규화의 성능
          • 데이터베이스구조와성능
          • 분산데이터베이스와성능
          • 대량 데이터에 따른 성능
          • 반정규화와 성능
          • 성능데이터모델링의 개요
        • 데이터모델링의이해
          • 식별자
          • 속성
          • 관계
          • 엔터티
          • 데이터 모델의 이해
    • DB
  • trouble
    • libomp
    • After macOS update, git command
    • system
  • algorithm
    • BOJ
      • 평범한 배낭
      • 17825-주사위윷놀이
      • 14888-연산자끼워넣기
      • 14503-로봇청소기
      • 10157
      • 14502-연구소
      • 18428-감시피하기
      • 14501
      • 18405-경쟁적전염
      • 14499-주사위굴리기
      • 16236-아기상어
      • 15686-치킨배달
      • 19237-어른상어
      • 16234-인구이동
      • 19236-청소년상어
      • 1339-단어수학
      • 리모콘
      • 18353 - 병사배치하기
      • 18352-특정거리의도시찾기
      • 12100-2048
      • N-Queen
      • 3190-뱀
      • 11724
    • programmers
      • 영어끝말잇기
      • 기둥과 보
      • H - index
      • 정수삼각형
      • 2018 KAKAO BLIND RECRUITMENT - 압축
      • 삼각달팽이
      • 거스름돈
      • [1차] 셔틀버스
    • data_structure
      • Queue
      • Graph
      • Stack
      • Hash table
    • implementation
      • dynamic_programming
      • sort
      • Least common multiple
      • dfs
      • dijkstra
      • bfs
      • binary_search
    • aps
      • notes
    • modules
  • python
    • requirements.txt
    • Jupyter notebook
    • 00_들어가기 전에
    • Python Virtual Environment
    • Python Syntax
  • django
    • Class Based View in Django
    • Model in Django
    • URL Name
    • Form and ModelForm
    • Authentication
    • Tips & Tricks
    • Optimization
    • Request and Response Objects
    • Templates
    • Variable Routing & DTL
    • Django REST API with JSON web token (JWT)
    • Intro to Django
    • Django REST Framework
    • Wrap-up
    • Image Upload
  • javascript
    • Ajax (Asynchronous Javascript And XML)
    • Document Object Model
    • Java Script 101
    • ES (ECMAscript)
  • java
    • Java 101
  • aws
    • beginning_cloud_computing_with_aws
      • 02 AWS 주요 서비스 이해하기
      • 01 아마존 웹 서비스 Cloud 개요
  • programming
    • Communication
    • CS_용어사전
  • vue.js
    • 01_Vue.js_Intro
  • data_science
    • 01_데이터에서인사이트발견하기
    • pandas
    • 04_데이터분류모델
    • 02_텍스트마이닝첫걸음
    • 05_종합예제
    • 03_미래를예측하는데이터분석
    • Statistics
      • 모수와 추정량
    • 통계학노트
  • linux
    • Linux Commands
  • ide
    • VScode
    • Pycharm
  • html,css
    • HTML 101
    • CSS 101
  • colab
    • colab_101
  • 의사결정나무및모형비교
Powered by GitBook
On this page

Was this helpful?

  1. algorithm
  2. BOJ

14499-주사위굴리기

Previous18405-경쟁적전염Next16236-아기상어

Last updated 4 years ago

Was this helpful?

  1. 주사위를 굴리는 방향에 따라서 1,2,3,4,5,6 면이 어떻게 바뀌는지 완탐해서 조건마다 굴린 후 주사위값을 정렬한다.

n, m, x, y, k = map(int,input().split())
a = [list(map(int,input().split())) for _ in range(n)]
# 0 이 주사위 놓는 위치 / 각 칸에는 0부터 10 사이의 수
move = list(map(int,input().split()))

#우, 좌, 상, 하
dx = [0, 0, -1, 1]
dy = [1, -1, 0, 0]

def roll(d):
    new_dice = [0, 0, 0, 0, 0, 0]
    if d == 1:
       new_dice[0] = dice[2]
       new_dice[1] = dice[1]
       new_dice[2] = dice[5]
       new_dice[3] = dice[0]
       new_dice[4] = dice[4]
       new_dice[5] = dice[3]
    elif d == 2:
        new_dice[0] = dice[3]
        new_dice[1] = dice[1]
        new_dice[2] = dice[0]
        new_dice[3] = dice[5]
        new_dice[4] = dice[4]
        new_dice[5] = dice[2]
    elif d == 3:
        new_dice[0] = dice[1]
        new_dice[1] = dice[5]
        new_dice[2] = dice[2]
        new_dice[3] = dice[3]
        new_dice[4] = dice[0]
        new_dice[5] = dice[4]
    elif d == 4:
        new_dice[0] = dice[4]
        new_dice[1] = dice[0]
        new_dice[2] = dice[2]
        new_dice[3] = dice[3]
        new_dice[4] = dice[5]
        new_dice[5] = dice[1]
    return new_dice

dice = [0, 0, 0, 0, 0, 0]
for i in move:
    nx = x + dx[i - 1]
    ny = y + dy[i - 1]
    if 0 <= nx < n and 0 <= ny < m:
        dice = roll(i)
        print(dice[5])
        if a[nx][ny]:
            dice[0] = a[nx][ny]
            a[nx][ny] = 0
        # 간 곳에 0이 쓰여있었다면
        else:
            a[nx][ny] = dice[0]
        x = nx
        y = ny
www.acmicpc.net/problem/14499