Deep Learning study

백준 14499문제 본문

백준 문제 코드

백준 14499문제

HwaniL.choi 2019. 12. 12. 20:39
반응형
#include <bits/stdc++.h>
using namespace std;

#define FOR(i,a,b) for(int i=a ; i<b ; i++)

int N,M,x,y,K; 
int MAP[21][21], dice[5] = {1,2,4,3,5}, dice_value[7], order[1001];

int main(){
    ios_base::sync_with_stdio(false);
    cin >> N >> M >> x >> y >> K;
    FOR(i,0,N) FOR(j,0,M) cin >> MAP[i][j];
    FOR(i,0,K) cin >> order[i];

    FOR(i,0,K){
        int ord = order[i];
        if(ord == 1){
            if(y+1>=M) continue;
            else{
                ++y;
                dice[2] = dice[0];
                dice[0] = dice[3];
                dice[3] = 7-dice[2];
            }
        }else if(ord == 2){
            if(y-1 < 0) continue;
            else{
                --y;
                dice[3] = dice[0];
                dice[0] = dice[2];
                dice[2] = 7 - dice[3];
            }
        }else if(ord == 3){
            if(x-1<0) continue;
            else{
                --x;
                dice[1] = dice[0];
                dice[0] = dice[4];
                dice[4] = 7-dice[1];
            }
        }else if(ord == 4){
            if(x+1>=N) continue;
            else{
                ++x;
                dice[4] = dice[0];
                dice[0] = dice[1];
                dice[1] = 7-dice[4];
            }
        }
        int idx = dice[0];
        if(MAP[x][y]){
            dice_value[7-idx] = MAP[x][y];
            MAP[x][y] = 0;
        }else MAP[x][y] = dice_value[7-idx];

        cout << dice_value[idx] << '\n';
    }

    return 0;
} 

백준 14499 주사위 굴리기 문제 입니다.

반응형

'백준 문제 코드' 카테고리의 다른 글

백준 3190문제  (0) 2019.12.16
백준 14500문제  (0) 2019.12.16
백준 14501문제  (0) 2019.12.10
백준 17135문제  (0) 2019.12.08
백준 3945문제  (0) 2019.12.08
Comments