728x90 Sort2 [programmers] Lv.4 동굴 탐험(c++) 4단계는 어려운거같다... 코드를 봐도 cycle을 의미한다하여 응? 왜 그게 cycle을 의미하는건데? 근본적인 질문이 떠오르고 내 방식대로 하려하면 왠지 너무 복잡해진다. 근데 대부분의 답은 내 방식대로 한게 맞는거같다.. 검색하다가 위상정렬(topology sort)라는 것을 알게됐다. (이 해설에 들어갔다가 알게됨 : https://2jinishappy.tistory.com/200, 풀이는 참고하지 않았고, 검색해서 찾아낸 위상 정렬을 설명해주고있는 아래 참고 링크에서 sort 원리만 참고했다.) 다른 방법들도 있는것 같았지만, 이게 제일 명확했다. 더보기 #include #include #include using namespace std; bool topology_sort(vector& di, .. 2022. 5. 5. [programmers] Lv.2 튜플(c++) 간단하게 끝낼 수 있는것은 간단하게 해결하자!! 는 생각이었다. 더보기 #include #include #include using namespace std; vector split(string str){ smatch match; vector res; while(regex_search(str, match, regex("(\\d|,)+"))){ string matched = match.str(); str = match.suffix().str(); str = str.substr(2); smatch number; vector inside; while(regex_search(matched, number, regex("\\d+"))){ inside.push_back(stoi(number.str())); matche.. 2022. 5. 4. 이전 1 다음 728x90