-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path14499.cpp
More file actions
129 lines (97 loc) · 2.15 KB
/
14499.cpp
File metadata and controls
129 lines (97 loc) · 2.15 KB
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
//
// 14499.cpp
// algo
//
// Created by 박효정 on 2021/06/16.
//
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int arr[21][21];
int d[7];
int main(){
cin.tie(0);
cout.tie(0);
std::ios::sync_with_stdio(false);
//세로 가로 좌표 명렬개수
int n,m,x,y,k;
cin>>n>>m>>x>>y>>k;
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
cin>>arr[i][j];
}
}
vector<int>v(k);
for(int i=0;i<k;i++){
cin>>v[i];
}
int d1=d[1];
int d2=d[2];
int d3=d[3];
int d4=d[4];
int d5=d[5];
int d6=d[6];
int nx=0;
int ny=0;
for(int i=0;i<k;i++){
nx=x;
ny=y;
d1=d[1];
d2=d[2];
d3=d[3];
d4=d[4];
d5=d[5];
d6=d[6];
//동쪽일때
//주사위 굴리기
if(v[i]==1){
ny=y+1;
if(ny<0||ny>=m||nx<0||nx>=n)continue;
y=ny;
d[3]=d1;
d[6]=d3;
d[4]=d6;
d[1]=d4;
}
//서쪽
else if(v[i]==2){
ny=y-1;
if(ny<0||ny>=m||nx<0||nx>=n)continue;
y=ny;
d[1]=d3;
d[6]=d4;
d[4]=d1;
d[3]=d6;
}
//남쪽
else if(v[i]==4){
nx=x+1;
if(ny<0||ny>=m||nx<0||nx>=n)continue;
x=nx;
d[6]=d5;
d[5]=d1;
d[1]=d2;
d[2]=d6;
}
//북쪽
else if(v[i]==3){
nx=x-1;
if(ny<0||ny>=m||nx<0||nx>=n)continue;
x=nx;
d[1]=d5;
d[2]=d1;
d[6]=d2;
d[5]=d6;
}
if(arr[x][y]==0){
arr[x][y]=d[6];
}
else{
d[6]=arr[x][y];
arr[x][y]=0;
}
cout<<d[1]<<"\n";
}
return 0;
}