title: Find number of ways to create sequence A of length n satisfying m conditions
body: <p>Find number of ways to create sequence A of length n satisfying m conditions. This sequence A should consist of only non negative numbers. Each condition is described by three integers (i,j,k) signifying max(A[i],A[j])=k.<br>It is guaranteed that each index of the sequence will be there in at least one condition i.e. there will be finite number of such sequences.<br>
  The maximum value of n will not exceed 18 and maximum value of k will not exceed 20000.
  <br>
  I tried it using dynamic programming but the time complexity came out to be exponential. Can you suggest me any better approach which will reduce the time complexity?</p>