Download spoj_cpp_clean/AIBOHP/AIBOHP-3.cpp from slayone/uva_spoj_raw: direct link, hf CLI and curl.
- Browser
- Download file 983 Bytes
-
https://huggingface.co/datasets/slayone/uva_spoj_raw/resolve/main/spoj_cpp_clean/AIBOHP/AIBOHP-3.cpp
- Command line
-
hf download hf://datasets/slayone/uva_spoj_raw/spoj_cpp_clean/AIBOHP/AIBOHP-3.cpp
-
curl -L -o AIBOHP-3.cpp https://huggingface.co/datasets/slayone/uva_spoj_raw/resolve/main/spoj_cpp_clean/AIBOHP/AIBOHP-3.cpp
983 Bytes
| using namespace std; | |
| int main(){ | |
| string s1; | |
| int t, dp[2][6101], l, indx; | |
| sd(t); | |
| while(t--){ | |
| cin>>s1; | |
| l = s1.length(); | |
| for(int i = 0; i <= l; i++){ | |
| dp[0][i] = 0; | |
| } | |
| indx = 0; | |
| for(int i = 1; i <= l; i++){ | |
| indx = 1 - indx; | |
| for(int j = 1; j <= l; j++){ | |
| if(s1[i-1] == s1[l-j]){ | |
| dp[indx][j] = dp[1-indx][j-1] + 1; | |
| } | |
| else{ | |
| dp[indx][j] = max(dp[1-indx][j], dp[indx][j-1]); | |
| } | |
| } | |
| } | |
| cout<<l - dp[indx][l]<<endl; | |
| } | |
| return 0; | |
| } | |