I can't implement the State-space tree. How to implement it for subset sum problem?
What's the complexity of this?
Thanks in advance.
# | User | Rating |
---|---|---|
1 | tourist | 3690 |
2 | jiangly | 3647 |
3 | Benq | 3581 |
4 | orzdevinwang | 3570 |
5 | Geothermal | 3569 |
5 | cnnfls_csy | 3569 |
7 | Radewoosh | 3509 |
8 | ecnerwala | 3486 |
9 | jqdai0815 | 3474 |
10 | gyh20 | 3447 |
# | User | Contrib. |
---|---|---|
1 | maomao90 | 174 |
2 | awoo | 165 |
3 | adamant | 161 |
4 | TheScrasse | 160 |
5 | nor | 158 |
6 | maroonrk | 156 |
7 | -is-this-fft- | 152 |
8 | orz | 146 |
9 | SecondThread | 145 |
9 | pajenegod | 145 |
I can't implement the State-space tree. How to implement it for subset sum problem?
What's the complexity of this?
Thanks in advance.
I have learned LIS with DP from MAXImal.But can not print the sequence. it just shows the longest length. if I want to print the sequence then what the modifies should I do.
http://e-maxx.ru/algo/longest_increasing_subseq_log
Here the code.
int main() { int n;
cin>>n; int dp[n+1],arr[n]; dp[0] = -INF; for(int i=0;i<n;i++){ scanf("%d",&arr[i]); dp[i+1]=INF; } for(int i=0;i<n;i++){ int j=upper_bound(dp,dp+n+1,arr[i])-dp; if(dp[j-1] < arr[i] && arr[i] < dp[j]) dp[j] = arr[i]; } for(int i: dp) cout<<i<<endl; return 0;
}
Sorry for my poor English.
Name |
---|