티스토리 뷰
핵심
비내림차 순이라는 것은 이전값 보다 크면 안된다는 얘기
구현
// 2020-06-23 wsshin
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;
void DFS(int n, int m, int nCur);
vector<int> vecOutPutData;
vector<int> vecVisited;
int main()
{
int n, m;
cin >> n >> m;
for (int i = 0; i < n; i++)
{
vecVisited.push_back(0);
}
DFS(n, m, 0);
return 0;
}
void DFS(int n, int m, int nCur)
{
if (nCur >= m)
{
for (int i = 0; i < vecOutPutData.size(); i++)
{
cout << vecOutPutData[i] << " ";
}
cout << "\n";
return;
}
for (int i = 0; i < n; i++)
{
if (!vecOutPutData.empty())
{
if (i + 1 < vecOutPutData.back()) continue;
}
vecOutPutData.push_back(i+1);
vecVisited[i] = 1;
DFS(n, m, nCur+1);
vecVisited[i] = 0;
vecOutPutData.pop_back();
}
return;
}
'Algoritem > Problem solving' 카테고리의 다른 글
프로그래머스 - 완주하지 못한 선수 (java) (0) | 2021.04.18 |
---|---|
백준 : 15649 N과 M(1)(C++14)_DFS, 백트레킹 (0) | 2020.05.26 |
팩토리얼 (0) | 2020.05.25 |
소수 판별법 (0) | 2020.05.25 |
백준 : 7576번 토마토(C++14)_BFS (0) | 2020.05.22 |
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- rotator
- double free
- LambdaFunction
- 람다
- c++
- Lambda
- C
- UE4
- 람다함수
- coordinate system
- unrealengine
- UE5
- c++11
- bug
- Trouble shooting
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
글 보관함