본문 바로가기

분류 전체보기439

2048(Hard) C++ https://www.acmicpc.net/ #include #include #include #include using namespace std; const int MAX = 25; int n; int map[MAX][MAX]; int answer = -1; void MoveBlock(int m[MAX][MAX], int count) { if (count == 10) { return; } int copy[MAX][MAX]; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { copy[i][j] = m[i][j]; } } for (int k = 0; k < 4; k++) { int max_v = -1; if (k == 0) { //아래 for (int.. 2022. 4. 7.
로봇 C++ https://www.acmicpc.net/problem/13901 13901번: 로봇 첫 번째 줄에는 방의 크기 R, C(3 ≤ R, C ≤ 1,000)가 입력된다. 두 번째 줄에는 장애물의 개수 k(0 ≤ k ≤ 1,000)가 입력된다. 다음 k개의 줄에는 각 장애물 위치 br(0 ≤ br ≤ R – 1), bc(0 ≤ bc ≤ C - 1)가 www.acmicpc.net #include #include #include using namespace std; struct MOVE { int x, y; }; MOVE mv[4] = { {-1,0}, {1,0}, {0,-1}, {0,1} }; //위, 아래, 왼쪽, 오른쪽 const int MAX = 1002; int map[MAX][MAX]; int r, .. 2022. 4. 6.
보이저 1호 https://www.acmicpc.net/problem/3987 3987번: 보이저 1호 첫째 줄에 시그널을 보내는 방향을 출력한다. (U: 위, R: 오른쪽, D: 아래, L: 왼쪽) 만약, 방향이 여러 가지가 존재한다면, U, R, D, L의 순서 중 앞서는 것을 출력한다. 둘째 줄에는 가장 긴 시간을 출 www.acmicpc.net #include #include #include using namespace std; struct MOVE { int x, y; }; MOVE mv[4] = { {-1,0}, {0,1}, {1,0}, {0,-1} }; //위, 오른쪽, 아래, 왼쪽 const int MAX = 505; char map[MAX][MAX]; int n, m; pair loc; int ans.. 2022. 4. 6.
거북이 C++ https://www.acmicpc.net/problem/8911 8911번: 거북이 첫째 줄에 테스트 케이스의 개수 T가 주어진다. 각 테스트 케이스는 한 줄로 이루어져 있고, 컨트롤 프로그램이 주어진다. 프로그램은 항상 문제의 설명에 나와있는 네가지 명령으로만 이루어져 www.acmicpc.net #include #include using namespace std; string cmd; int left_i, left_j, right_i, right_j; int cur_i, cur_j; int cur_dir; // 0:북 1:남 2:동 3:서 int main(void) { int testcase; cin >> testcase; for (int i = 0; i .. 2022. 4. 5.