Algorithm(218)
-
[BOJ] 14500번 : 테트로미노
1. problem : https://www.acmicpc.net/problem/14500 2. solution 1 :#include using namespace std;#define X first #define Y second int n, m;int board[502][502]; int ans = -1;vector> v;bool isbound(vector> v) {// 범위에 있는지 확인하는 함수 for (auto s : v) { if (s.X = n || s.Y = m) return false; } return true;}int cal_sum(vector> v) { int sum = 0; for (auto s : v) { sum += board[s.X][s.Y]; } return sum;}vo..
2024.08.23 -
[BOJ] 3190번 : 뱀
1. problem : https://www.acmicpc.net/problem/3190 2. solution 1 :#include using namespace std;#define X first#define Y second int n, k, l; // board 크기, 사과 개수, 방향 변환 횟수;int board[102][102];int isvis[102][102]; int dx[4] = { -1,0,1,0 };int dy[4] = { 0,1,0,-1 };pair head = { 0,0 };deque> snake;queue> dir_loc; // 방향변환 저장 bool isover = false; // game 끝났는지int gametime;int curdir = 1;void go(int dir)..
2024.08.23 -
[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