| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
Why WA????#include<iostream>
#include<algorithm>
using namespace std;
int d[1024];
int main()
{
int i,N,n,k,s;
scanf("%d",&N);
while(N--)
{
scanf("%d %d",&n,&k);
for(i=0;i<n;i++) scanf("%d",&d[i]);
s=0;
do
{
for(i=0;i<n;i++)
if(d[i]!=(n-i)) break;
if(i==n)
{
for(i=0;i<n;i++) d[i]=i+1;
s++;
}
if(s==k)
{
for(i=0;i<n;i++) printf("%d ",d[i]);
printf("\n");
break;
}
s++;
}while(next_permutation(d,d+n));
}
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator