4 해설
题解与来源题共享。已有题解默认通过;新增或编辑后需由来源域管理员审核。待审核、驳回题解仅作者和审核管理员可见。来源域:system
-
0
想按字典序输出调换选和不选顺序就行
#include<bits/stdc++.h> using namespace std; using ll=long long; int n; vector<int>path; void dfs(int x){ if(x>n){ for(auto i:path)cout<<i<<" "; cout<<endl; return ; } //不选 dfs(x+1); //选 path.push_back(x); dfs(x+1); path.pop_back(); } int main(){ cin>>n; dfs(1); }
정보
- ID
- 35
- 시간
- 1000ms
- 메모리
- 256MiB
- 난이도
- 普及−
- 태그
- 제출 기록
- 358
- 맞았습니다.
- 172
- 아이디