Tangram
Ghép 7 mảnh xoay & lật
Luyện tập / Chủ đề Logic · Tư duy
Bài tập suy luận logic, nhận diện quy luật, bài toán cân đo, câu đố chiến thuật và tư duy thuật toán.
Đăng nhập để lưu tiến độ và tích lũy điểm trên bảng xếp hạng.
[Part C · Hard] In the Knuth–Morris–Pratt (KMP) string-matching algorithm, the prefix array $\pi[i]$ stores the length of the longest proper prefix of P[0..i] that is also a suffix of P[0..i] (proper means strictly shorter than P[0..i]). For pattern P = "ABABACA" ($7$ characters, $0$-indexed $i = 0..6$), compute the sum $\pi[0] + \pi[1] + \pi[2] + \pi[3] + \pi[4] + \pi[5] + \pi[6]$.
Trong thuật toán so khớp chuỗi KMP, mảng tiền tố $\pi[i]$ lưu độ dài tiền tố thực sự dài nhất của xâu con P[0..i] đồng thời cũng là hậu tố của P[0..i]. Với xâu mẫu P = "ABABACA" ($7$ ký tự, chỉ số $i = 0..6$), tính tổng $\pi[0] + \pi[1] + \dots + \pi[6]$? (Chỉ điền số)
Đáp án: $7$
Answer / Đáp án: 7
Step-by-step (EN): Compute $\pi[i]$ for each prefix of "ABABACA":
i=0 ("A"): $0$i=1 ("AB"): $0$i=2 ("ABA"): $1$ ("A")i=3 ("ABAB"): $2$ ("AB")i=4 ("ABABA"): $3$ ("ABA")i=5 ("ABABAC"): $0$i=6 ("ABABACA"): $1$ ("A").Sum $= 0 + 0 + 1 + 2 + 3 + 0 + 1 = 7$.
Giải chi tiết (VI): Tính lần lượt $\pi[i]$ cho từng tiền tố của "ABABACA":
"A" $\to 0$; "AB" $\to 0$; "ABA" $\to 1$ ("A"); "ABAB" $\to 2$ ("AB"); "ABABA" $\to 3$ ("ABA"); "ABABAC" $\to 0$; "ABABACA" $\to 1$ ("A").Tổng các phần tử là $0 + 0 + 1 + 2 + 3 + 0 + 1 = 7$.
Computational Thinking / Tư duy Máy tính: KMP Prefix Automaton / Failure Function (Hàm thất bại trong so khớp xâu tuyến tính KMP).
[Part C · Hard] Consider the 2-SAT Boolean formula with $4$ variables $(x_1, x_2, x_3, x_4) \in \{\text{True}, \text{False}\}^4$: $$(x_1 \lor x_2) \land (\neg x_1 \lor x_3) \land (\neg x_2 \lor x_3) \land (\neg x_3 \lor x_4) \land (\neg x_4 \lor \neg x_3).$$ How many truth assignments $(x_1, x_2, x_3, x_4)$ satisfy the entire formula?
Xét công thức logic 2-SAT gồm $4$ biến Boole $(x_1, x_2, x_3, x_4) \in \{\text{Đúng}, \text{Sai}\}^4$: $$(x_1 \lor x_2) \land (\neg x_1 \lor x_3) \land (\neg x_2 \lor x_3) \land (\neg x_3 \lor x_4) \land (\neg x_4 \lor \neg x_3).$$ Có bao nhiêu bộ giá trị chân lý $(x_1, x_2, x_3, x_4)$ làm cho toàn bộ công thức nhận giá trị Đúng?
Đáp án: $0$ (Unsatisfiable)$0$ (Vô nghiệm)
Answer / Đáp án: $0$ (Unsatisfiable / Vô nghiệm)
Step-by-step (EN): Convert clauses $A \lor B \equiv (\neg A \Rightarrow B)$: 1) Last two clauses $(\neg x_3 \lor x_4) \land (\neg x_4 \lor \neg x_3)$ give $x_3 \Rightarrow x_4 \Rightarrow \neg x_3$, forcing $x_3 = \text{False}$. 2) With $x_3 = \text{False}$, clauses $(\neg x_1 \lor x_3)$ and $(\neg x_2 \lor x_3)$ force $x_1 = \text{False}$ and $x_2 = \text{False}$. 3) That violates the first clause $(x_1 \lor x_2)$! Hence $0$ satisfying assignments.
Giải chi tiết (VI): Biến đổi về kéo theo logic: 1) Hai mệnh đề cuối $(\neg x_3 \lor x_4)$ và $(\neg x_4 \lor \neg x_3)$ kéo theo $x_3 \Rightarrow x_4 \Rightarrow \neg x_3$, buộc $x_3 = \text{Sai}$. 2) Thay $x_3 = \text{Sai}$ vào $(\neg x_1 \lor x_3)$ và $(\neg x_2 \lor x_3)$ buộc cả $x_1 = \text{Sai}$ và $x_2 = \text{Sai}$. 3) Khi đó mệnh đề đầu $(x_1 \lor x_2)$ bị Sai! Vậy có $0$ bộ nghiệm thỏa mãn.
Computational Thinking / Tư duy Máy tính: 2-SAT Implication Graphs & Unit Propagation (Đồ thị suy diễn 2-SAT).
[Part C · Hard] In the Byzantine Generals Problem, $n$ distributed servers communicate via point-to-point messages to reach strict consensus, even if up to $f$ servers are Byzantine faulty (they may lie, collude, and send contradictory messages to different peers, without cryptographic signatures). According to Lamport, Shostak, and Pease's Theorem, what is the minimum total number of servers $n$ required to tolerate $f = 2$ Byzantine traitors?
Trong bài toán Các vị tướng Byzantine của hệ thống phân tán, $n$ máy chủ trao đổi thông điệp trực tiếp để đạt đồng thuận ngay cả khi có tối đa $f$ máy chủ bị lỗi kiểu Byzantine (có thể gửi thông tin giả mạo, mâu thuẫn cho các máy khác mà không dùng chữ ký số). Theo định lý kinh điển của Lamport – Shostak – Pease, cần tối thiểu bao nhiêu máy chủ $n$ để chịu được $f = 2$ máy phản bội?
Đáp án: $n = 7$
Answer / Đáp án: $n = 7$
Step-by-step (EN): Byzantine Fault Tolerance (BFT) without digital signatures requires strictly more than two-thirds honest nodes: $$n \geqslant 3f + 1.$$ For $f = 2$, the minimum number of servers is $n = 3(2) + 1 = 7$.
Giải chi tiết (VI): Để đạt đồng thuận chịu lỗi Byzantine (BFT), tổng số nút phải lớn hơn $3$ lần số nút lỗi: $$n \geqslant 3f + 1.$$ Với $f = 2$, số máy chủ tối thiểu cần có là $n = 3 \times 2 + 1 = 7$.
Computational Thinking / Tư duy Máy tính: Distributed Consensus & Byzantine Fault Tolerance $3f + 1$ (Đồng thuận phân tán & Chịu lỗi Byzantine).
In schedule #6, four independent jobs take 4, 5, 6, 5 minutes. With $2$ identical workers working in parallel (each job runs on $1$ worker without interruption), what is the minimum total time to finish all $4$ jobs?
Đáp án: $10$
Chia tối ưu thành 2 nhóm có thời gian gần nhau nhất, thời gian hoàn thành ngắn nhất là $10$ phút.
Cipher #6 shifts every letter forward by $5$ positions in the alphabet (A→F, B→G, ...). How is ANT encrypted?
Đáp án: FSY
Dịch mỗi chữ cái tiến $5$ bước thu được FSY.
A robot starts facing North and executes Turn Right 90° exactly $26$ times. Which direction is it facing at the end?
Đáp án: South
Sau mỗi $4$ lần quay $90^\circ$ robot lại hướng North. Vì $26 : 4$ dư $2$, robot hướng South.