Download uva_cpp_clean/10066/10066-9.cpp from slayone/uva_spoj_raw: direct link, hf CLI and curl.
- Browser
- Download file 659 Bytes
-
https://huggingface.co/datasets/slayone/uva_spoj_raw/resolve/main/uva_cpp_clean/10066/10066-9.cpp
- Command line
-
hf download hf://datasets/slayone/uva_spoj_raw/uva_cpp_clean/10066/10066-9.cpp
-
curl -L -o 10066-9.cpp https://huggingface.co/datasets/slayone/uva_spoj_raw/resolve/main/uva_cpp_clean/10066/10066-9.cpp
659 Bytes
| using namespace std; | |
| const int MAX_N = 1e2 + 10; | |
| int n1, n2, arr1[MAX_N], arr2[MAX_N], dp[MAX_N][MAX_N]; | |
| int lcs () { | |
| for (int i = 1; i <= n1; i++) { | |
| for (int j = 1; j <= n2; j++) { | |
| if (arr1[i - 1] == arr2[j - 1]) dp[i][j] = 1 + dp[i - 1][j - 1]; | |
| else dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]); | |
| } | |
| } | |
| return dp[n1][n2]; | |
| } | |
| int main () { | |
| int tc = 0; | |
| while (cin >> n1 >> n2, n1 or n2) { | |
| for (int i = 0; i < n1; i++) cin >> arr1[i]; | |
| for (int i = 0; i < n2; i++) cin >> arr2[i]; | |
| printf("Twin Towers #%d\n", ++tc); | |
| printf("Number of Tiles : %d\n", lcs()); | |
| puts(""); | |
| } | |
| return (0); | |
| } | |