회원가입
로그인
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
글쓰기
질문 도움말
자주묻는 질문
반례를 도저히 못찾겠습니다...
2713번 - 규현이의 사랑을 담은 문자메시지
rhkddh1909
2년 전
0
도저히 모르겠습니다.. 도와주세요 ㅠㅠ
#define _CRT_SECURE_NO_WARNINGS #include #include #include #include #include #include using namespace std; \ string make_binary(char ch); void draw(int r, int c, string str); int main(void) { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int t; cin >> t; for (int i = 0; i < t; i++) { int r, c; cin >> r >> c; string str; cin.ignore(1,'\n'); getline(cin,str); string answer = ""; for (int i = 0; i < str.length(); i++) { if (str[i] == ' ') { answer += "00000"; } else { answer += make_binary(str[i]); } } draw(r, c, answer); } return 0; } string make_binary(char ch) { int tmpint = ch - 'A' + 1; string tmpstr= "00000"; int idx = 4; char charr[2] = {'0','1'}; while (tmpint != 0) { tmpstr[idx] = charr[tmpint%2]; tmpint = tmpint / 2; idx--; } return tmpstr; } void draw(int r, int c, string str) { char **a = new char*[r+1]; for (int i = 0; i < r; i++) { a[i] = new char[c+1]; } int** chk = new int* [r+1]; for (int i = 0; i < r; i++) { chk[i] = new int[c+1]; } for (int i = 0; i < r; i++) { for (int j = 0; j < c; j++) { chk[i][j] = 0; a[i][j] = '0'; } } int x[4] = {1,0,-1,0}; int y[4] = {0,1,0,-1}; int posx = 0; int posy = 0; int command = 0; chk[0][0] = 1; a[0][0] = str[0]; for (int i = 1; i < str[i]; i++) { if (0 <= (posx + x[command]) && (posx+x[command]) < c && 0 <= (posy + y[command]) && (posy + y[command]) < r && chk[posy + y[command]][posx + x[command]] == 0) { posx = posx + x[command]; posy = posy + y[command]; a[posy][posx] = str[i]; chk[posy][posx] = 1; } else { command = (command+1)%4; if (0 <= (posx + x[command]) && (posx + x[command]) < c && 0 <= (posy + y[command]) && (posy + y[command]) < r && chk[posy + y[command]][posx + x[command]] == 0) { posx = posx + x[command]; posy = posy + y[command]; a[posy][posx] = str[i]; chk[posy][posx] = 1; } } } for (int i = 0; i < r; i++) { for (int j = 0; j < c; j++) { cout << a[i][j]; } } cout << endl; }
댓글을 작성하려면
로그인
해야 합니다.
rhkddh1909 2년 전
도저히 모르겠습니다.. 도와주세요 ㅠㅠ