✅ What I did today
- 프로그래머스
- 데브시스터즈 코테 : 2/3솔
- 웹 자체 ide 절대 쓰지 말고 visual studio로만 작성할 것
- 최소 우선순위 큐 선언할 때 자료형 int 아니면 다른 것도 int에서 바꿔줘야 함
- 조금 절어도 시간 많으니까 침착하게 문제 처음부터 끝까지 다 읽고 풀 것
- 무지성으로 인덱스 작성하지 말고 접근하는 인덱스가 무슨 의미인지 생각하기
- 분명 다른거 전부 double로 선언돼있는데도 손 나가는대로 변수를 int로 선언해버리지 말기
- Atcoder
⚔️ 프로그래머스
하노이의 탑
#include <string>
#include <vector>
using namespace std;
vector<vector<int>> hanoi(int disk, int from, int to)
{
if (disk == 1) return { {from,to} };
vector<vector<int>> res;
for (vector<int> move : hanoi(disk - 1, from, 6 - from - to)) {
res.push_back(move);
}
res.push_back({from,to});
for (vector<int> move : hanoi(disk - 1, 6 - from - to, to)) {
res.push_back(move);
}
return res;
}
vector<vector<int>> solution(int n) {
return hanoi(n, 1, 3);
}