当前位置:网站首页>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] << ' ';
}
边栏推荐
- Brick story
- [LeetCode]-二分查找
- C language learning log 1.2
- Implementing the driver registration initcall mechanism on stm32
- rainbow
- Embedded hardware: electronic components (1) resistance capacitance inductance
- Trust programming - linked lists: use struct to implement linked lists, use heap to merge K ascending linked lists, and customize display
- Simple-SR:Best-Buddy GANs for Highly Detailed Image Super-Resolution論文淺析
- OJ problem solution summary
- The processing flow of thread pool depends on the core parameters
猜你喜欢

Sampo Lock

Logical point

Chapter 13 abstraction: address space

CMB written test graphical reasoning

详解OpenCV的函数cv::add(),并附各种情况的示例代码和运行结果

2021TPAMI/图像处理:Exploiting Deep Generative Prior for Versatile Image Restoration and Manipulation

Win8.1和Win10各自的优势

约瑟夫问题

C language learning log 12.14

Reductive elimination
随机推荐
Clause 32: moving objects into closures using initialization capture objects
C language learning log 10.11
How to understand JS expressions and JS statements
[leetcode]- sliding window
MySQL8.0.13安装教程(有图)
Trust programming - linked lists: use struct to implement linked lists, use heap to merge K ascending linked lists, and customize display
Design system based on MVC using javeswingjdbc
Solution to sudden font change in word document editing
Kaggle time series tutorial
Shell built-in string substitution
Clause 31: avoid default capture mode
CMB's written test -- data analysis
[JS solution] leedcode 117 Populate the next right node pointer II for each node
Elliptic curve encryption
PostgreSQL Guide: inside exploration (Chapter 10 basic backup and point in time recovery) - Notes
详解OpenCV的函数cv::add(),并附各种情况的示例代码和运行结果
C language learning log 10.8
Flutter dart variables and constants
Cesium:cesiumlab makes image slices and loads slices
[JS solution] leedcode 200 Number of islands