-
백준 15663번: N과 M(9)문제해결 2023. 11. 29. 16:51
N과 M(9)
함수딸깍#include <bits/stdc++.h> using namespace std; #define endl "\n" #define FOR(i, N) for (int i = 0; i < static_cast<int>(N); i++) int N, M; vector<int> arr; int main() { cin.tie(NULL)->sync_with_stdio(false); cin >> N >> M; FOR(i, N) { int num; cin >> num; arr.push_back(num); } sort(arr.begin(), arr.end()); do { FOR(i, M) cout << arr[i] << " "; cout << endl; reverse(arr.begin() + M, arr.end()); } while (next_permutation(arr.begin(), arr.end())); return 0; }
'문제해결' 카테고리의 다른 글
백준 1260번: DFS와 BFS (0) 2023.11.30 백준 1629번: 곱셈 (0) 2023.11.28 백준 11687번: 팩토리얼 0의 개수 (0) 2023.11.28 백준 23253번: 자료구조는 정말 최고야 (0) 2023.11.28 백준 9251번: LCS, 백준 5582번: 공통 부분 문자열 (2) 2023.11.20