Time Limit: 1000MS | Memory Limit: 30000K | |
Total Submissions: 9466 | Accepted: 4183 |
Description
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
Source
Source Code
Problem: 1833 | User: bingshen | |
Memory: 148K | Time: 485MS | |
Language: C++ | Result: Accepted |
#include<stdio.h> #include<algorithm> using namespace std; int a[1200]; int main() { int t,n,k,i; scanf("%d",&t); while(t--) { scanf("%d%d",&n,&k); for(i=0;i<n;i++) scanf("%d",&a[i]); for(i=0;i<k;i++) next_permutation(a,a+n); for(i=0;i<n-1;i++) printf("%d ",a[i]); printf("%d/n",a[n-1]); } return 0; }