전체 글(331)
-
[BOJ] 14503번 : 로봇 청소기
1. problem : https://www.acmicpc.net/problem/14503 2. solution 1 :#include using namespace std;int n, m, x, y, dir;int room[52][52]; int dx[4] = { -1,0,1,0 }; // 북, 동, 남, 서;int dy[4] = { 0,1,0,-1 }; // 북, 동, 남, 서;bool isgo(int x, int y) { // 동서남북에 청소 안된 곳이 있는지 체크 for (int i = 0; i > n >> m; cin >> x >> y >> dir; for (int i = 0; i > room[i][j]; } int curX = x, curY = y, curdir = dir; while (1)..
2024.08.22 -
[BOJ] 16985번 : Maaaaaaaaaze
1. problem : https://www.acmicpc.net/problem/16985 2. solution 1 :#include using namespace std;int board[5][5][5]; // 원본 배열int board2[5][5][5]; // 사본 배열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 };int vis[5][5][5];queue> Q;int ans = 0x7f7f7f7f;void rotate(int idx, int rot) { while (rot--) { int temp[5][5]; for (int i..
2024.08.22 -
[BOJ] 13335번 : 트럭
1. problem : https://www.acmicpc.net/problem/13335 2. solution 1 :#include using namespace std;int n, w, L; int cars[1002];int main(void) { ios::sync_with_stdio(0); cin.tie(0); cin >> n >> w >> L; for (int i = 0; i > cars[i]; int current_weight = 0; int idx = 0; int time = 0; queue bridge; while (!bridge.empty() || idx chatGPT가 짜주었다. queue를 이용한 풀이다. 나는 큐를 이용해서 풀이를 진행하려했으나, 연속적인 값을 처리하지 못해..
2024.08.22 -
[BOJ] 14499번 : 주사위 굴리기
1. problem : https://www.acmicpc.net/problem/14499 2. solution 1 :#include using namespace std;#define X first#define Y secondint n, m, x, y, k; int board[24][24]; int dice[8]; // 원본 순서저장 ;int dice2[8]; // 복사본 순서저장 ;//명령은 반복문 안에서 받자. void change_dice(int dir) { if (dir == 1) { dice2[0] = dice[2]; dice2[1] = dice[1]; dice2[2] = dice[5]; dice2[3] = dice[0]; dice2[4] = dice[4]; dice2[5] = dic..
2024.08.22 -
[C++] deque를 다룰때
1. 서론 난 지금까지 deque를 하나의 seq로 밖에 사용하지 못한다고생각했다. 하지만, deque의 배열을 만들 수 있다. deque 4개를 품고있는 dq[4]를 정의하면 된다. deque의 배열: deque dq[4];는 4개의 deque를 저장하는 배열이다. 여기서 dq[0], dq[1], dq[2], dq[3] 각각이 독립적으로 문자를 저장할 수 있다. 2. 본론#include using namespace std;int main(void) { ios::sync_with_stdio(0); cin.tie(0); deque dq[4]; int k = 2; for (int i = 0; i > s; dq[i] = deque(s.begin(), s.end()); } for (int i = 0; i ..
2024.08.21 -
[BOJ] 14891번 : 톱니바퀴
1. problem : https://www.acmicpc.net/problem/14891 2. solution 1 :#include using namespace std;string board[4];int K; // Test case의 수 deque dq1;deque dq2;deque dq3;deque dq4;void rotate(int w,deque& dq) { if (w == 1) { dq.push_front(dq.back()); dq.pop_back(); } if (w == -1) { dq.push_back(dq.front()); dq.pop_front(); }}int main(void) { ios::sync_with_stdio(0); cin.tie(0); for (int i = 0; i ..
2024.08.21