Editorial for Parallel 2 (DHBB 2021 T.Thử)
Remember to use this editorial only when stuck, and not to copy-paste code from it. Please be respectful to the problem author and editorialist.
Submitting an official solution before solving the problem yourself is a bannable offence.
Submitting an official solution before solving the problem yourself is a bannable offence.
\(\color{red}{\text{Spoiler Alert}_{{}_{{}^{{}^{v2.0}}}}}\)
\(\color{red}{\text{Khuyến khích bạn đọc trước khi đọc phần lời giải xin hãy thử code ra thuật của mình dù nó có sai hay đúng}}\)
\(\color{red}{\text{Sau đó từ phần bài giải và thuật toán trước đó mà đối chiếu, rút nhận xét với thuật của mình và thu được bài học (không lãng phí thời gian đâu).}}\)
\(\color{goldenrod}{\text{Tiếp cận}}\)
-
Có \(q\) truy vấn
-
Mỗi truy vấn nhận vào \(a, b\). Điều kiện để in "Yes" là $(x \leq 2\ $ & \(\ y \leq 1)\) hoặc $(x \leq 1\ $ & \(\ y \leq 2)\). Ngược lại in "No"
\(\color{green}{\text{Code tham khảo }}\): Approach
\(^{^{\color{purple}{\text{Độ phức tạp : }} O(q)\ \color{purple}{\text{thời gian}}\ ||\ O(q)\ \color{purple}{\text{bộ nhớ}}}}\)
C++
#include <iostream>
using namespace std;
int main()
{
int q;
cin >> q;
while (q-->0)
{
int x, y;
cin >> x >> y;
cout << ((x <= 2 && y <= 1) || (x <= 1 && y <= 2) ? "Yes" : "No") << '\n';
}
return 0;
}
Comments