단계별로 풀어보기 - 백트래킹- 8단계 https://www.acmicpc.net/problem/14889 #include #include using namespace std; int N,ans=987654321; int table[20][20]; bool pick[20]; void dfs(int count,int key) { int sum1=0,sum2=0; if(key==N) { return; } if(count==N/2) { for(int i=0;iN; for(int i=0;itable[i][j]; } } dfs(0,0); cout
단계별로 풀어보기 - 백트래킹- 7단계 https://www.acmicpc.net/problem/14888 #include using namespace std; int N; int operators[4]; int num[11]; int Min=1000000001; int Max=-1000000001; void check(int result,int key) { if(key==N) { if(result>Max) { Max=result; } if(result>N; for(int i=0;i>num[i]; } for(int i=0;i>operators[i]; } check(num[0],1); cout
단계별로 풀어보기 - 백트래킹- 6단계 https://www.acmicpc.net/problem/2580 #include using namespace std; int board[10][10]; bool col[10][10],row[10][10],rect[10][10]; void dfs(int key) { int x=key/9; int y=key%9; if(key==81) { for(int i=0;i
단계별로 풀어보기 - 백트래킹- 5단계 https://www.acmicpc.net/problem/9663 #include using namespace std; int N,board[15],count=0; void dfs(int x) { if (x==N) { count++; return; } for(int i=0;iN; dfs(0); cout
단계별로 풀어보기 - 백트래킹- 4단계 https://www.acmicpc.net/problem/15652 #include using namespace std; int N,M; int arr[8]={}; bool visit[8]={}; void dfs(int num,int count) { if(count==M) { for(int i=0;i
단계별로 풀어보기 - 백트래킹- 3단계 https://www.acmicpc.net/problem/15651 #include using namespace std; int N,M; int arr[8]={}; bool visit[8]={}; void dfs(int count) { if(count==M) { for(int i=0;i