회원가입
로그인
Toggle navigation
문제
문제
전체 문제
문제 출처
단계별로 풀어보기
알고리즘 분류
추가된 문제
문제 순위
문제
푼 사람이 한 명인 문제
아무도 못 푼 문제
최근 제출된 문제
최근 풀린 문제
랜덤
출처
ICPC
Olympiad
한국정보올림피아드
한국정보올림피아드시․도지역본선
전국 대학생 프로그래밍 대회 동아리 연합
대학교 대회
카카오 코드 페스티벌
Coder's High
ICPC
Regionals
World Finals
Korea Regional
Africa and the Middle East Regionals
Europe Regionals
Latin America Regionals
North America Regionals
South Pacific Regionals
문제집
대회
채점 현황
랭킹
게시판
그룹
더 보기
재채점 기록
블로그
강의
실험실
도움말
BOJ Stack
BOJ Book
전체
공지
자유
질문
오타/오역/요청
게시판 공지
홍보
업데이트
solved.ac
글쓰기
질문 도움말
자주묻는 질문
트...렷스..ㅂㄴㅣ다...도와주세요
14499번 - 주사위 굴리기
anminyeong
6년 전
0
테케 다 맞았는데 바로 틀렷다고 나오네요...?
봐주시겠어요?
import java.util.ArrayList; import java.util.List; import java.util.Scanner; public class Main{ static int[] row = {0,0,-1,1}; static int[] col = {1,-1,0,0}; static int[] dice = {0,0,0,0,0,0,0}; static int[] xdice = {0,0,0,0,0,0,0}; static int[][] map; static int nr = 0; static int nc = 0; public static void main(String[] args){ Scanner sc = new Scanner(System.in); int[] tern = new int[1000]; int n = sc.nextInt(); int m = sc.nextInt(); nr = sc.nextInt(); nc = sc.nextInt(); int tcase = sc.nextInt(); map = new int[n][m]; for(int i=0;i<n;i++){ for(int j=0;j<m;j++){ map[i][j] = sc.nextInt(); } } for(int t=0; t<tcase ;t++){ tern[t] = sc.nextInt(); } List<Integer> myList = new ArrayList<Integer>(); for(int s=0;s<tcase;s++){ if(tern[s]==1){ if(nc+1 == m) continue; nc++; dicetop(1); stamp(map,nr,nc); }else if(tern[s]==2){ if(nc-1 < 0) continue; nc--; dicetop(2); stamp(map,nr,nc); }else if(tern[s]==3){ if(nr-1 < 0) continue; nr--; dicetop(3); stamp(map,nr,nc); }else if(tern[s]==4){ if(nr+1 == n) continue; nr++; dicetop(4); stamp(map,nr,nc); } diceset(); myList.add(dice[6]); } for(int value : myList){ System.out.println(value); } } public static void stamp(int[][] m, int r, int c){ if(0 == m[r][c]) m[r][c] = dice[1]; dice[1] = m[r][c]; m[r][c] = 0; } public static void diceset(){ for(int i=0;i<7;i++){ xdice[i] = dice[i]; } } public static void dicetop(int d){ if(d==1){ dice[1] = xdice[3]; dice[2] = xdice[2]; dice[3] = xdice[6]; dice[4] = xdice[1]; dice[5] = xdice[5]; dice[6] = xdice[4]; }else if(d==2){ dice[1] = xdice[4]; dice[2] = xdice[2]; dice[3] = xdice[1]; dice[4] = xdice[6]; dice[5] = xdice[5]; dice[6] = xdice[3]; }else if(d==3){ dice[1] = xdice[2]; dice[2] = xdice[6]; dice[3] = xdice[3]; dice[4] = xdice[4]; dice[5] = xdice[1]; dice[6] = xdice[5]; }else if(d==4){ dice[1] = xdice[5]; dice[2] = xdice[1]; dice[3] = xdice[3]; dice[4] = xdice[4]; dice[5] = xdice[6]; dice[6] = xdice[2]; } } }
댓글을 작성하려면
로그인
해야 합니다.
anminyeong 6년 전
테케 다 맞았는데 바로 틀렷다고 나오네요...?
봐주시겠어요?