Bộ Dụng Cụ 14 Món Bấm Móng tay Có Hộp Đựng, Chăm Sóc Bàn Tay Bàn Chân, Nhỏ Gọn Tiện Lợi Mang Theo Làm Nail Mọi Lúc
Bộ Dụng Cụ 14 Món Bấm Móng tay ...
49.999₫ 10.000₫
Bút bi gel shinshin mực màu đen 0.5mm (thiết kết hoạt hình dễ thương) , Hàng mới về, Thiết kế hoạt hình đơn giản và dễ thương, Thích hợp cho học sinh, Nét bút 0,5mm, Màu đen, 6 bút / bộ
Bút bi gel shinshin mực màu ...
12.000₫ 24.000₫

Bài tậpBài chưa trả lời

Https://lqdoj.edu.vn/problem/dplcs2

https://lqdoj.edu.vn/problem/dplcs2
1 Xem trả lời
Hỏi lại yêu cầu
93
Tham khảo câu trả lời từ Trợ lý ảo Lazi
I’m not able to open that link directly. Could you please share the problem statement here (paste the text), or at least describe:

- Input format and constraints
- What exactly to output (LCS length, number of LCS, count modulo something, number of distinct LCS, etc.)
- Any special requirements (time/memory limits, multiple test cases, reconstruction needed, large inputs, etc.)
- A sample input and output

If you’d like, I can provide a general solution template for common DPLCS-type problems. Here are a few possibilities and how I’d approach them:

1) Longest Common Subsequence length (classic)
- DP: dp[i][j] = LCS length of first i chars of A and first j chars of B
- Recurrence:
- if A[i-1] == B[j-1], dp[i][j] = dp[i-1][j-1] + 1
- else dp[i][j] = max(dp[i-1][j], dp[i][j-1])
- Optimization: O(nm) time, O(min(n,m)) memory with rolling arrays
- Simple reconstruction can be added if needed

2) Number of LCS (counting how many LCS sequences)
- You can extend the DP to count ways, being careful with duplicates:
- If A[i-1] == B[j-1], dpLen[i][j] = dpLen[i-1][j-1] + 1
count[i][j] = count[i-1][j-1]
- Else:
- if dpLen[i-1][j] > dpLen[i][j-1], take from top
- if <, take from left
- if equal, sum counts from top and left (and subtract from top-left if dpLen[i-1][j-1] == dpLen[i][j])
- This gets tricky to avoid counting duplicates; I can provide a robust version if that’s your goal.

3) Number of distinct LCS (unique sequences)
- Much trickier; typically requires careful handling to avoid duplicates, sometimes with sets or more advanced DP-with-next-array optimizations.
- I can tailor this if you confirm it’s the “distinct” variant.

4) Large alphabets or special constraints
- If strings are huge, we might need optimizations like bitset-based LCS (for binary alphabet or small alphabets) or patience/suffix-automaton tricks for variants.

If you share the problem text, I’ll tailor a precise solution (with code in C++, Python, or Java) to match DPLCS2’s exact requirements.
1 trả lời
1
1
Yamamoto Hitomi
04/11/2025 19:56:56
ko thấy câu hỏi =))

Mở khóa để xem toàn bộ nội dung trả lời

(?)
Bạn đã đạt đến giới hạn của mình. Bằng cách Đăng ký tài khoản, bạn có thể xem toàn bộ nội dung trả lời
Cải thiện điểm số của bạn bằng cách đăng ký tài khoản Lazi.
Xem toàn bộ Trả lời và Chat với Trợ lý ảo Lazi AI bằng cách Đăng nhập tài khoản ngay bây giờ
Tôi đã có tài khoản? Đăng nhập

Bạn hỏi - Lazi trả lời

Bạn muốn biết điều gì?

GỬI CÂU HỎI
Câu hỏi mới nhất

Hôm nay bạn thế nào? Hãy nhấp vào một lựa chọn, nếu may mắn bạn sẽ được tặng 50.000 xu từ Lazi

Vui Buồn Bình thường
Máy Pha Cà Phê Espresso Winci EM4212 ( Giá đã bao gồm VAT ), Tay cầm 51 MM Pha Cafe Tự Động, Công Suất 1350w, Áp Suất 20Bar, tặng 1 gói cafe , 1 Tamper 51 mm 1 Ca inox
Máy Pha Cà Phê Espresso Winci EM4212 ( Giá đã bao gồm VAT ), Tay cầm 51 MM Pha ...
-38% 4.331.360₫ 6.992.857₫
Máy tính bảng viết LCD cho trẻ em, bảng vẽ kích thước 8.5/12 inch, bảng viết LCD với màn hình xóa chỉ bằng một nút, đồ chơi bảng vẽ tay
Máy tính bảng viết LCD cho trẻ em, bảng vẽ kích thước 8.5/12 inch, bảng viết LCD ...
268.000₫
×
Mua sắm
+Gửi câu hỏi LAZI MALL
+500xu
×