/***
Md. Namzul Hasan
Shahjalal University of Science & Technology,Sylhet.
hasan08sust@gmail.com
***/
#include<bits/stdc++.h>
using namespace std ;
typedef long long ll ;
typedef int in ;
typedef unsigned long long ull ;
const double pi = 2*acos(0) ;
#define maxi 40000
#define pf printf
#define sc scanf
#define pb push_back
#define MEM(x,y) (memset((x),(y),sizeof(x)))
#define MIN(x,y) ((x) < (y) ? (x) : (y))
#define MAX(x,y) ((x) > (y) ? (x) : (y))
#define load(array,size) for(int i=0 ; i<size ; i++) cin>>array[i] ;
#define new_line pf("\n")
#define clear_data(array) memset(array,0,sizeof(array))
#define highest_int 2147483647
vector<int> G ;
int p[10001] ;
int k ;
void backtrack(int pos)
{
if(G.size()==6)
{
pf("%d",G[0]) ;
for(int i=1 ; i<G.size() ; i++)
pf(" %d",G[i]) ;
pf("\n") ;
return ;
}
for(int j =pos+1 ; j<k ; j++)
{
int m = p[j] ;
G.pb(m) ;
backtrack(j) ;
G.pop_back() ;
}
}
int main()
{
int l =0 ;
while(sc("%d",&k)==1)
{
if(k==0)
break ;
G.clear() ;
for(int i=0 ; i<k ; i++)
sc("%d",&p[i]) ;
if(l)
pf("\n") ;
l=1 ;
backtrack(-1) ;
}
}
Md. Namzul Hasan
Shahjalal University of Science & Technology,Sylhet.
hasan08sust@gmail.com
***/
#include<bits/stdc++.h>
using namespace std ;
typedef long long ll ;
typedef int in ;
typedef unsigned long long ull ;
const double pi = 2*acos(0) ;
#define maxi 40000
#define pf printf
#define sc scanf
#define pb push_back
#define MEM(x,y) (memset((x),(y),sizeof(x)))
#define MIN(x,y) ((x) < (y) ? (x) : (y))
#define MAX(x,y) ((x) > (y) ? (x) : (y))
#define load(array,size) for(int i=0 ; i<size ; i++) cin>>array[i] ;
#define new_line pf("\n")
#define clear_data(array) memset(array,0,sizeof(array))
#define highest_int 2147483647
vector<int> G ;
int p[10001] ;
int k ;
void backtrack(int pos)
{
if(G.size()==6)
{
pf("%d",G[0]) ;
for(int i=1 ; i<G.size() ; i++)
pf(" %d",G[i]) ;
pf("\n") ;
return ;
}
for(int j =pos+1 ; j<k ; j++)
{
int m = p[j] ;
G.pb(m) ;
backtrack(j) ;
G.pop_back() ;
}
}
int main()
{
int l =0 ;
while(sc("%d",&k)==1)
{
if(k==0)
break ;
G.clear() ;
for(int i=0 ; i<k ; i++)
sc("%d",&p[i]) ;
if(l)
pf("\n") ;
l=1 ;
backtrack(-1) ;
}
}
No comments:
Post a Comment