标签:ring tput name src lang namespace str efi vector
Input
Output
Sample Input
3 3 1 2 3 1 3 1 3 2 1 10 2 1 2 3 4 5 6 7 8 9 10
Sample Output
3 1 2 1 2 3 1 2 3 4 5 6 7 9 8 10
【代码】:
#include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <set> #include <map> #include <list> #include <deque> #include <queue> #include <stack> #include <string> #include <vector> #include <numeric> #include <sstream> #include <iostream> #include <algorithm> #include <functional> using namespace std; typedef long long ll; #pragma comment(linker, "/STACK:102400000,102400000") #define Abs(x) ((x^(x >> 31))-(x>>31)) #define Swap(a,b) (a^=b,b^=a,a^=b) #define PI acos(-1.0) #define INF 0x3f3f3f3f #define EPS 1e-8 #define MOD 1000000007 #define max_ 10005 #define maxn 200002 using namespace std; int a[1200]; int main() { int t; int n,k; scanf("%d",&t); while(t--) { scanf("%d %d",&n,&k); for(int i=0;i<n;i++) { scanf("%d",&a[i]); } for(int i=0;i<k;i++) { next_permutation(a,a+n); } for(int i=0;i<n-1;i++) printf("%d ",a[i]); printf("%d\n",a[n-1]); } return 0; }
POJ 1833 排列【STL/next_permutation】
标签:ring tput name src lang namespace str efi vector
原文地址:http://www.cnblogs.com/Roni-i/p/7835387.html