当前位置:网站首页>Luogu p1088 Martians
Luogu p1088 Martians
2022-06-13 05:00:00 【Clown clown clown】
Topic link : Martian
Knowledge point
next_permutation Use . notes :C There is no such function in the language .
next_permutation Is to find the total permutation of a sequence , A sequence slightly larger than the current sequence dictionary order ( only ).
for example 1 2 3 4 5 Of next_permutation yes 1 2 3 5 4, Once again next_permutation yes 1 2 5 3 4.
If it keeps going next_permutation Words , Until it becomes 5 4 3 2 1( The maximum order of the current sequence dictionary )
The meaning of this question is that a sequence is sorted according to the size of the dictionary order in the whole arrangement , mapping 1,2,3,….
So with next_permutation Just right .
AC Code :
#include <iostream>
#include <algorithm>
using namespace std;
const int N = 10010;
int n, m;
int a[N];
int main()
{
cin >> n >> m;
string s,t;
for (int i = 0; i < n; i++) cin >> a[i];
for (int i = 0; i < m; i++) next_permutation(a, a + n);
for (int i = 0; i < n; i++) cout << a[i] << ' ';
}
边栏推荐
- Bomb disposal cat
- Nodejs parsing get request URL string
- Clause 26: avoid overloading universal reference types
- Clause 34: lambda is preferred over std:: bind
- Interpretation of QT keypressevent
- rainbow
- About mission planning and improving execution
- Force buckle 25 A group of K flipped linked lists
- Reductive elimination
- Stepping on a horse (one stroke)
猜你喜欢
Advanced C - Section 2 - pointers
C language exercise 1
Section 4 - arrays
Win8.1和Win10各自的优势
Mysql8.0.13 installation tutorial (with pictures)
[leetcode]- binary search
Createanonymousthreadx passes parameters to anonymous threads
CMB's written test -- data analysis
Sampo Lock
Solution to sudden font change in word document editing
随机推荐
小C的记事本
C language learning log 10.19
Elliptic curve encryption
Mysql8.0.13 installation tutorial (with pictures)
Promise processing JS multithreads get the same processing result after all the results are obtained
The games that you've tasted
C language learning log 1.22
Chapter 17 free space management
Little C's Notepad
Robot pose description and coordinate transformation
shell变量学习笔记
Draw a hammer
Section 7 - structures
C language learning log 10.4
Chapter 15 mechanism: Address Translation
CMB written test graphical reasoning
C language learning log 10.8
Must know must know -c language keywords
Section 4 - arrays
Explain the opencv function cv:: add() in detail, and attach sample code and running results of various cases