회원가입
로그인
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
문제집
대회
1
채점 현황
랭킹
게시판
그룹
더 보기
재채점 기록
블로그
강의
실험실
도움말
BOJ Stack
BOJ Book
전체
공지
자유
질문
오타/오역/요청
게시판 공지
홍보
업데이트
solved.ac
글쓰기
질문 도움말
자주묻는 질문
출력형식이 잘못된 이유를 모르겠습니다
6593번 - 상범 빌딩
njs04210
3년 전
0
테스트는 잘 통과하는데 자꾸 출력형식이 잘못됐다고하네요.. 어디가 문제인걸까요?
#include <cstring> #include <iostream> #include <queue> using namespace std; const int MAX = 31; char building[MAX][MAX][MAX]; int visited[MAX][MAX][MAX]; int dx[6] = {1, -1, 0, 0, 0, 0}; int dy[6] = {0, 0, 1, -1, 0, 0}; //동서남북상하 int dz[6] = {0, 0, 0, 0, -1, 1}; struct Loc { int z, y, x, cnt; Loc(int a, int b, int c, int d) { z = a; y = b; x = c; cnt = d; } }; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int L, R, C; //L 층수 R 행 C 열 while (1) { cin >> L >> R >> C; queue<Loc> Q; bool flag = false; memset(building, 0, sizeof(building)); memset(visited, 0, sizeof(visited)); if (L == 0 && R == 0 && C == 0) // 0 0 0 입력시 종료 return 0; for (int i = 0; i < L; i++) { for (int j = 0; j < R; j++) { for (int u = 0; u < C; u++) { cin >> building[i][j][u]; if (building[i][j][u] == 'S') { Q.push(Loc(i, j, u, 0)); visited[i][j][u] = 1; } } } if (i != L - 1) cout << "\n"; } while (!Q.empty()) { Loc tmp = Q.front(); Q.pop(); if (building[tmp.z][tmp.y][tmp.x] == 'E') { cout << "Escaped in " << tmp.cnt << " minute(s)." <<"\n"; flag = true; break; } for (int i = 0; i < 6; i++) { int nextX = tmp.x + dy[i]; int nextY = tmp.y + dx[i]; int nextZ = tmp.z + dz[i]; int time = tmp.cnt; if (nextX >= 0 && nextX < C && nextY >= 0 && nextY < R && nextZ >= 0 && nextZ < L) { if ((building[nextZ][nextY][nextX] == '.' || building[nextZ][nextY][nextX] == 'E') && visited[nextZ][nextY][nextX] == 0) { Q.push(Loc(nextZ, nextY, nextX, time + 1)); visited[nextZ][nextY][nextX] = 1; } } } } if (!flag) cout << "Trapped!" << "\n"; cout << "\n"; } return 0; }
댓글을 작성하려면
로그인
해야 합니다.
njs04210 3년 전
테스트는 잘 통과하는데 자꾸 출력형식이 잘못됐다고하네요.. 어디가 문제인걸까요?