当前位置:网站首页>Acwing 94. recursive implementation of permutation enumeration
Acwing 94. recursive implementation of permutation enumeration
2022-07-24 20:30:00 【To catty Hawthorn】
#include<iostream>
#include<vector>
using namespace std;
int n;
vector<int> path;
// For each number, there are two schemes: select and deselect , If elected , Data in path,state Set up 1, Finally, reply to the scene .
// Enumerate until all numbers are enumerated .
//u Indicates how many numbers are currently selected ,state Status of each number
void dfs(int u,int state){
if(u == n){
for(auto x:path) cout << x << ' ';
cout << endl;
return;
}
for(int i = 0;i < n;i++){
if(!(state >> i & 1)){
path.push_back(i + 1);
dfs(u + 1,state | 1 << i);
path.pop_back();
}
}
}
int main()
{
cin >> n;
dfs(0,0);
return 0;
}
边栏推荐
- Browser local storage webstroage
- Bypass using the upper limit of the maximum number of regular backtracking
- Home Assistant中接入博联WiFi智能遥控
- Microservice architecture | service monitoring and isolation - [sentinel] TBC
- How to learn automated testing
- Each blogger needs to ask himself seven basic questions
- Failed to create a concurrent index, leaving an invalid index. How to find it
- Monotone stack and monotone queue (linear complexity optimization)
- PHP page Jump mode
- Sql164 next day retention rate of new users per day in November 2021
猜你喜欢

What does software testing need to learn?

Unitywebgl project summary (unfinished)

Leetcode 146: LRU cache

Alibaba sentinel basic operation

Login Huawei device in SSH mode

Appium element positioning - App automated testing

BGP - border gateway protocol

Do you want to enroll in a training class or study by yourself?

whistle ERR_ CERT_ AUTHORITY_ INVALID

vlan技术
随机推荐
Generate self signed certificate: generate certificate and secret key
How to learn automated testing
Pix2seq: Google brain proposes a unified interface for CV tasks!
Leetcode 48 rotating image (horizontal + main diagonal), leetcode 221 maximum square (dynamic programming DP indicates the answer value with ij as the lower right corner), leetcode 240 searching two-d
Vscode connected to the remote server cannot format the code / document (resolved)
Transport layer protocol parsing -- UDP and TCP
[msp430g2553] graphical development notes (2) system clock and low power consumption mode
Covid-19-20 - basic method of network segmentation based on vnet3d
Hcip early summary
Processing of null value of Oracle notes
Markdown to PDF API data interface
[training Day9] rotate [violence] [thinking]
clip:learning transferable visual models from natural language supervision
[feature selection] several methods of feature selection
Mass modify attribute values in objects in JS
Opengl rendering pipeline
Understand the domestic open source Magnolia license series agreement in simple terms
Synthesis of peptide nucleic acid PNA labeled with heptachydrin dye cy7 cy7-pna
Click the button to return to the top smoothly
Wechat stores build order pages and automatically grab tickets