-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโll occasionally send you account related emails.
Already on GitHub? Sign in to your account
24-seongwon030 #88
24-seongwon030 #88
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
์ฃผ์ฌ์๊ฐ ๊ตด๋ ค์ง ๋ ๋ง๋ค ๊ตด๋ ค์ง๋ ๋ฐฉํฅ๋ณ๋ก ๊ฐ๊ฐ ๋ฉด์ ๋ํ ๋ฐ์ดํฐ๋ฅผ ์ ๋ฐ์ดํธ ํด์ฃผ๋ ๋ฐฉ์ ์ ๋ดค์ต๋๋ค. ๋จธ๋ฆฌ๋ก ์ดํดํ ๋๋ง ํด๋ ์ฃผ์ฌ์ ๋ฐฉ๋ฉด์ ์ฒดํฌํด์ค ๋ ๋ง๋ค ๊ณ ์ญ์ด์๋๋ฐ ์ฝ๋๋ฅผ ์ง๊ณ ๋ณด๋ฉด ๋๊ฒ ๊ฐํธํ๋ค์..!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
n, m, x, y, k = map(int, input().split())
board = []
dx = [0, 0, -1, 1]
dy = [1, -1, 0, 0]
dice = [0, 0, 0, 0, 0, 0]
def turn(dir):
a, b, c, d, e, f = dice[0], dice[1], dice[2], dice[3], dice[4], dice[5]
if dir == 1: #๋
dice[0], dice[1], dice[2], dice[3], dice[4], dice[5] = d, b, a, f, e, c
elif dir == 2: #์
dice[0], dice[1], dice[2], dice[3], dice[4], dice[5] = c, b, f, a, e, d
elif dir == 3: #๋ถ
dice[0], dice[1], dice[2], dice[3], dice[4], dice[5] = e, a, c, d, f, b
else:
dice[0], dice[1], dice[2], dice[3], dice[4], dice[5] = b, f, c, d, a, e
for i in range(n):
board.append(list(map(int, input().split())))
comm = list(map(int, input().split()))
nx, ny = x, y
for i in comm:
nx += dx[i-1]
ny += dy[i-1]
if nx < 0 or nx >= n or ny < 0 or ny >= m:
nx -= dx[i-1]
ny -= dy[i-1]
continue
turn(i)
if board[nx][ny] == 0:
board[nx][ny] = dice[-1]
else:
dice[-1] = board[nx][ny]
board[nx][ny] = 0
print(dice[0])
์์ค ์ด ๊ฑฐ ๋ฌธ์ ํ๋ค๊ฐ ๋ฌธ์ ๋ฅผ ์๋ชป ์ฝ์ด์ 3์๊ฐ ๋ ๋ฆฌ๊ณ ๊ทธ๋ฅ ๋ฝ์ด ์ณ๋ฒ๋ ค์ ์์นญํด์ ๋ ํผ๋ฐ์ค ๋ณด๊ณ ํ์์ต๋๋ค.
์์ค!!!!!!!!!!!!!!!!!!!!!!!!!!
์ ๋ ์ฒ์์ ๋ค 0์ผ๋ก ์ด๊ธฐํ๋์ด์๋๋ฐ, ์๋ฉด์ด 1์ด๊ณ ๋์ชฝ๋ฉด์ด 3์ธ์ฑ๋ก ์์ํ๋ ์ค ์์์ด์.
ํ ;;;;;;;;;;
์ ๋ ์ฃผ์ฌ์ ์ ๊ฐ๋ ๋์ ์ดํดํ๋๋ฐ ๋ง์ด ๊ฑธ๋ ธ์ต๋๋ค. ๋์๋จ๋ถ ๋ฐฉํฅ์ ๋จผ์ ์ ์ก๊ณ ๊ฐ์ผ ํ๋๋ผ๊ณ ์. ์คํธ๋ ์ค ๋ง๋ ์ธ ๋ฌธ์ ์์ต๋๋ค! ใ ใ ใ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
๊ตฌํ๋ฌธ์ .. ์ฌ๋ฐ๋ค์ ํํ
๋ฌธ์ ์์ ์๊ตฌํ๋๋๋ก ๋ฐ๋ผ๊ฐ๋ฉด์ ํ์๋๋ฐ..
์ฃผ์ฌ์ ๊ตด๋ฆฌ๋ ๋ถ๋ถ์์ index ์คํ 1๊ฐ ๋๋ฌธ์ 40๋ถ๋์ ์ณ๋ค๋ณด๊ณ ์์๋ค์ ..ใ
.ใ
..ใ
ใ
.ใ
.ใ
..ใ
.ใ
ใ
.ใ
..ใ
.ใ
๊ฐ๋ง์ ์ฌ๋ฐ๋ ๋ฌธ์ ์ ํ์์ต๋๋ค ~~
import sys
def input() : return sys.stdin.readline().rstrip()
N, M, x, y, K = map(int, input().split())
board = [[] for _ in range(N)]
dice = [0 for _ in range(6)]
cmd = []
for i in range(N):
board[i].extend(list(map(int, input().split())))
cmd.extend(map(int, input().split()))
def check(x, y):
if x < 0 or y < 0 or y >= M or x >= N:
return False
return True
def roll(n):
if n == 1:
dice[0], dice[2], dice[3], dice[5] = dice[2], dice[5], dice[0], dice[3]
elif n == 2:
dice[0], dice[2], dice[3], dice[5] = dice[3], dice[0], dice[5], dice[2]
elif n == 3:
dice[0], dice[1], dice[4], dice[5] = dice[4], dice[0], dice[5], dice[1]
else:
dice[0], dice[1], dice[4], dice[5] = dice[1], dice[5], dice[0], dice[4]
def copy(x, y):
if board[x][y] == 0:
board[x][y] = dice[5]
else:
dice[5] = board[x][y]
board[x][y] = 0
# ๋ 1 ์ 2 ๋ถ 3 ๋จ 4
dic_x, dic_y = x,y # ์ฃผ์ฌ์ ์์น ์ด๊ธฐํ
#print(dice)
for i in range(len(cmd)):
nx, ny = dic_x, dic_y
# ์ผ๋จ ํด๋น ์์น๋ก ์ด๋
if cmd[i] == 1:
ny += 1
elif cmd[i] == 2:
ny -= 1
elif cmd[i] == 3:
nx -= 1
elif cmd[i] == 4:
nx += 1
else: continue
if check(nx, ny):
dic_x, dic_y = nx, ny
roll(cmd[i])
copy(dic_x, dic_y)
#print(dice)
print(dice[0])
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
์๋ ์ด๊ฑธ ์ด๋ ๊ฒ ์ผ์ผ์ด ๋ค ์์ง์์ ๊ตฌํํด์ ํ์ด ใ ใ ใ ์ถ์๋๋ฐ ์์ ์ ํผ ์ ํ์ด๋ฅผ ๋ณด๋ ์ด๊ฒ ์ ๋ฐฐ์ธ ๊ฒ ๊ฐ๋ค์ ใ ใ
์ด๋ฐ ๊ตฌํ ๋ฌธ์ ๊ฐ ์ฝ๋ ์์ฑ์ ์กฐ๊ธ ๋จธ๋ฆฌ์ํ๊ธด ํด๋ ํธ๋ ์ฌ๋ฏธ๊ฐ ์๋ ๊ฒ ๊ฐ์์ ใ ใ
#include <iostream>
#include <vector>
#include <math.h>
#include <algorithm>
using namespace std;
enum dir {
NONE,
RIGHT,
LEFT,
FRONT,
BACK
};
const int DIR[5][2] = {
{ 0, 0 },
{ 0, 1 },
{ 0, -1 },
{ -1, 0 },
{ 1, 0 }
};
struct dice {
int up = 0;
int front = 0;
int back = 0;
int down = 0;
int right = 0;
int left = 0;
};
void moveDice(dice &d, int dir) {
int tUp, tFront, tBack, tDown, tRight, tLeft;
if (dir == FRONT) {
tRight = d.right;
tLeft = d.left;
tFront = d.up;
tDown = d.front;
tBack = d.down;
tUp = d.back;
}
else if (dir == RIGHT) {
tFront = d.front;
tBack = d.back;
tRight = d.up;
tDown = d.right;
tLeft = d.down;
tUp = d.left;
}
else if (dir == BACK) {
tRight = d.right;
tLeft = d.left;
tFront = d.down;
tDown = d.back;
tBack = d.up;
tUp = d.front;
}
else {
tFront = d.front;
tBack = d.back;
tRight = d.down;
tDown = d.left;
tLeft = d.up;
tUp = d.right;
}
d.right = tRight;
d.left = tLeft;
d.front = tFront;
d.down = tDown;
d.back = tBack;
d.up = tUp;
}
void printDice(dice d) {
printf("0 %d 0\n", d.front);
printf("%d %d %d\n", d.left, d.up, d.right);
printf("0 %d 0\n", d.back);
printf("0 %d 0\n\n", d.down);
}
bool isn(int t, int a, int b) {
if (t >= a && t < b) return true;
return false;
}
dice d;
int arr[21][21] = { 0, };
int dicePos[2] = { 0, 0 };
int n;
int main() {
int x, y, a;
cin >> x >> y >> dicePos[0] >> dicePos[1] >> n;
for (int i = 0; i < x; i++) {
for (int j = 0; j < y; j++) {
cin >> arr[i][j];
}
}
while (n--) {
cin >> a;
if (isn(dicePos[0] + DIR[a][0], 0, x) && isn(dicePos[1] + DIR[a][1], 0, y)) {
dicePos[0] += DIR[a][0];
dicePos[1] += DIR[a][1];
moveDice(d, a);
if (arr[dicePos[0]][dicePos[1]]) {
d.down = arr[dicePos[0]][dicePos[1]];
arr[dicePos[0]][dicePos[1]] = 0;
}
else {
arr[dicePos[0]][dicePos[1]] = d.down;
}
printf("%d\n", d.up);
}
}
}
๐ ๋ฌธ์ ๋งํฌ
์ฃผ์ฌ์๊ตด๋ฆฌ๊ธฐ
โ๏ธ ์์๋ ์๊ฐ
4์๊ฐ
โจ ์๋ ์ฝ๋
์ค๋๋ง์ ๊ตฌํ๋ฌธ์ ๋ฅผ ํ์ด๋ดค์ต๋๋ค. ์ฃผ์ฌ์ ๊ตฌํ์์ ๋จธ๋ฆฌ๊ฐ .. ์ํ ์ง๋ง ์ด์ฐ์ ์ฐ ํ์์ต๋๋ค.
์ฃผ์ฌ์
์ฃผ์ฌ์ ์ ๊ฐ๋๋ฅผ ํ ๋๋ก ์ฃผ์ฌ์ ์ธ๋ฑ์ค ์์๋ฅผ
์ผ์ชฝ์๋ฉด - ๋ถ์ชฝ๋ฉด - ์๋ฉด - ์ค๋ฅธ์ชฝ์๋ฉด - ๋จ์ชฝ๋ฉด - ์๋ซ๋ฉด
์ ์์๋ก ๊ฐ์ ํ๋ค.๋จผ์ ์ฃผ์ฌ์๊ฐ ๋/์๋ก ๊ตด๋ฌ๊ฐ ๋์ ๋ถ/๋จ์ผ๋ก ๊ตด๋ฌ๊ฐ ๋๋ฅผ ๋ถ๋ฆฌํด์ ์๊ฐํด๋ดค๋ค.
์ฃผ์ฌ์ ๋ถ์ชฝ๋ฉด๊ณผ ๋จ์ชฝ๋ฉด์ ๋ณํ์ง ์๋๋ค.
์ค๋ฅธ์ชฝ์ผ๋ก ๊ตด๋ฌ๊ฐ๋ ์ฃผ์ฌ์์ ์ซ์๋ค์
์->๋
์ผ๋ก ํ ์นธ์ฉ ์ด๋ํ๊ฒ ๋๋ค.๋ฆฌ์คํธ์ ์ด์ ์ธ๋ฑ์ค์ ์ซ์๋ก ๋ชจ๋ ์ธ๋ฑ์ค๋ฅผ ๋ฐ๊ฟ์ค๋ค.
์์ชฝ์ ๋ฐ๋๋ก ์๊ฐํ๋ค.
์ฃผ์ฌ์์ ์ผ์ชฝ ์๋ฉด๊ณผ ์ค๋ฅธ์ชฝ ์๋ฉด์ ๋ณํ์ง ์๋๋ค.
๋ถ์ชฝ์ผ๋ก ๊ตด๋ฌ๊ฐ๋ ์ฃผ์ฌ์์ ์ซ์๋ค์
๋จ->๋ถ
์ผ๋ก ํ ์นธ์ฉ ์ด๋ํ๊ฒ ๋๋ค.๋จ์ชฝ ๋ํ ๋ฐ๋๋ก ์๊ฐํ๋ค.
์กฐ๊ฑด
์ ์ฒด์ฝ๋
๐ ์๋กญ๊ฒ ์๊ฒ๋ ๋ด์ฉ
๋ง์ง๋ง ์กฐ๊ฑด์ 0์ผ๋ก ๋ฐ๊พธ์ด์ฃผ์ง ์์ 1์๊ฐ์ ๋ ์ผ์ต๋๋ค. ๋ฌธ์ ๋ฅผ ์ ์ฝ์ด์ผ ํ๋๋ฐ ํํ.. ์ค๋๋ง์ ๊ตฌํ๋ฌธ์ ์ญ์ ์ฌ๋ฐ๋ค์.