본문 바로가기

분류 전체보기150

[백준] 13459번 구슬 탈출 #include #define fastio cin.tie(0)->sync_with_stdio(0)using namespace std;struct step{ int Rx, Ry; int Bx, By; int Count;};char mapp[11][11];bool visited[11][11][11][11];int N,M;int dx[]={1,-1,0,0}; // 아래, 위, 오, 왼int dy[]={0,0,1,-1};void move(int& rx, int& ry, int& distance, int& i){ while(mapp[rx+dx[i]][ry+dy[i]] !='#' && mapp[rx][ry] !='O') { rx+=dx[i]; ry+=dy[i]; .. 2025. 5. 22.
[프로그래머스] sliding window-광고 삽입 #include #define fastio cin.tie(0)->sync_with_stdio(0)using namespace std;int arr[360010]; // 최대 재생 시간int time_to_sec(string time){ int h=stoi(time.substr(0,2)); //인덱스 0부터 2글자 뗴오기 int m=stoi(time.substr(3,2)); int s=stoi(time.substr(6,2)); return 3600*h+60*m+s;}string time_tostring(int t){ string ret=""; int h=t/3600; t%=3600; int m=t/60; int s=t%60; ret += h>=10 ?.. 2025. 4. 27.
[프로그래머스] 기둥과 보 설치 #include #define fastio cin.tie(0)->sync_with_stdio(0)using namespace std;vector>> Map;bool check(int x, int y, int a){ if(a==0){ // 기둥 if(!y // 바닥위 || (y-1>=0 && Map[0][x][y-1]) //다른 기둥 위 || Map[1][x][y] //보의 오른쪽 끝 위 || (x-1>=0 && Map[1][x-1][y])) //보의 왼쪽 끝 위 return true; } else{ if((y-1>=0 && Map[0][x][y-1]) // 왼쪽 끝 아래가 기둥 .. 2025. 4. 25.
[프로그래머스] 표편집 string solution(int n, int k, vector cmd){ vector prev(n), next(n); stack removed; for(int i=0; i1) value = stoi(s.substr(2)); if(command == 'U'){ while(value--){ cur=prev[cur]; } } else if(command == 'D'){ while(value--){ cur=next[cur]; } } else if(command == 'C'){ removed.push(cur.. 2025. 4. 25.